def get_msg_count(bag, topic):
    """Get number of instances for the topic.

    # Parameters
    bag : rosbag.Bag
        a target rosbag
    topic : string
        a valid topic name

    # Returns
    num_msgs : int
        number of messages in the topic
    """
    return bag.get_message_count(topic)