def add_matches(flight_matches, flight_ids):
    """
    Add new matches to the flight_ids dict.

    Returns the number of newly matched flights.

    """
    matches = 0

    for i in flight_matches.index:
        prev_id = flight_matches.loc[i, 'FLIGHT_ID_x']
        next_id = flight_matches.loc[i, 'FLIGHT_ID_y']
        if next_id not in flight_ids:
            flight_ids[next_id] = prev_id
            matches += 1

    return matches