Get search result count in plugin

Let’s what can be done. Try the bellow code. First I’m checking if it’s search query. Then trying to get the count from global query.

function search_count(){
    if(is_search()){
        global $wp_query;
        $not_singular = $wp_query->found_posts > 1 ? 'results' : 'result'; 
        echo $wp_query->found_posts . " $not_singular found";
    }
}

tech