POSITION SHORTCODE OUTPUT

Hi, I would like to display buddypress user notification count in the frontend. I have some code, that is working. To use it I was told to create a shortcode and it looks something like this:

function cg_current_user_notification_count() {
    $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object');
    $count = !empty($notifications) ? count($notifications) : 0;

    echo $count;
}
     add_shortcode ( 'alert', 'cg_current_user_notification_count');

The problem is, that the output is in the wrong place. I know I'm supposed to use something like ob_start() and ob_get_clean() but can someone please show me the exact code to use..

If you are not sure what my question is, please look here: https://wp-types.com/forums/topic/shortcode-output-showing-up-in-the-wrong-place/

Here is what I mean:

I want the 2 (count) to appear in between "have" and "notifications". This is my html:
<p>you have [alert] notifications</p>
Thanks!! :smile: