How to get Count of Lessons in a course in cakephp?

Thanks in advance!

I am new to CakePHP, and I am trying to get just count of lessons of course. I am using CakePHP with friendsofcake's crud.

$this->Crud->on('beforePaginate', function(\Cake\Event\Event $event) {
    $query = $event->getSubject()->query;

    $query->contain(['Lessons']);

});

with this code, I am getting all the lessons of the course, but I need only counts, because if a course having 50 lessons, why I should get all the lessons?

Output:-

App\Model\Entity\Course Object
(
    [id] => 7
    [language_id] => 2
    [course_title] => test
    [course_desc] => 
    [audio_path] => 
    [img_path] => 
    [inappiosid] => 
    [inappandroidid] => 
    [sOrder] => 1
    [lessons] => Array
        (
            [0] => App\Model\Entity\Lesson Object
                (
                    [id] => 4
                    [course_id] => 7
                    [lesson_title] => test
                    [lesson_description] => test
                    [file_path] => test
                    [sOrder] => 1
                    [[new]] => 
                    [[accessible]] => Array
                        (
                            [course_id] => 1
                            [lesson_title] => 1
                            [lesson_description] => 1
                            [file_path] => 1
                            [sOrder] => 1
                            [course] => 1
                        )
                )
        )
    [[new]] => 
    [[accessible]] => Array
        (
            [language_id] => 1
            [course_title] => 1
            [course_desc] => 1
            [audio_path] => 1
            [img_path] => 1
            [inappiosid] => 1
            [inappandroidid] => 1
            [sOrder] => 1
            [language] => 1
            [customer_orders] => 1
            [lessons] => 1
        )
)