Well, I have found myself the solution and wanted to share in a case if somebody else will need it. So I have created a plugin and here is the bunch of the code of the plugin needed to extract number of unread message:
class test extends rcube_plugin{
public $task='mail';
function init(){
$this->register_handler('plugin.unreadmessage',array($this, 'unreadmessage_handler'));
}
function unreadmessage_handler(){
$rcmail = rcmail::get_instance();
$count=$rcmail->imap->messagecount('INBOX', 'UNSEEN');
return $count
}
}
Use it for your use!