from datetime import datetime


def month_counter(fm, LAST_DAY_OF_TRAIN_PRD=(2015, 10, 31)):
    """Calculate number of months (i.e. month boundaries) between the first
    month of train period and the end month of validation period.

    Parameters:
    -----------
    fm : datetime
        First day of first month of train period

    Returns:
    --------
    Number of months between first month of train period and end month of validation period
    """
    return (
        (datetime(*LAST_DAY_OF_TRAIN_PRD).year - fm.year) * 12
        + datetime(*LAST_DAY_OF_TRAIN_PRD).month
        - fm.month
    )