paginating model, get count()

I have this code (Yii paging), how can I get the number of total records fetched?


$criteria=new CDbCriteria;        

        $criteria->order='date_date DESC';        

        $criteria->condition=' date_date=:time1';

        $month = date('n', $_GET['time']);        

        $year = date('Y', $_GET['time']);

        $day = date('d', $_GET['time']);

        if ($_GET['pnc'] == 'n') $month++;

        if ($_GET['pnc'] == 'p') $month--;

        $criteria->params[':time1']=  "$year-$month-$day";        

        

        $pages=new CPagination(calendars::model()->count($criteria));

        $pages->pageSize=20;

        $pages->applyLimit($criteria);

        

        $posts=calendars::model()->findAll($criteria);

should be $pages->itemCount

http://www.yiiframework.com/doc/api/CPagination