def is_valid(str):
    # dd-mm-yyyy
    if str[2] != '-' or str[5] != '-':
        return False
    day = str[0:2]
    month = str[3:5]
    year = str[6:10]
    if '-' in day or '-' in month or '-' in year:
        return False
    day = int(day)
    month = int(month)
    year = int(year)
    if year <2013 or year > 2015:
        return False
    if month < 1 or month > 12:
        return False
    days = [31,28,31,30,31,30,31,31,30,31,30,31]
    if day > days[month-1] or day < 1:
        return False
    return True


def get_prophecy_date(text):
    i = 0
    date_count = {}
    count = len(text)
    max_count = 0
    max_date = None
    while ((i+9) < count):
        temp = text[i:i+10]
        if is_valid(temp):
            if temp not in date_count:
                date_count[temp] = 0
            date_count[temp] += 1
            if date_count[temp] > max_count:
                max_count = date_count[temp]
                max_date = temp
        i += 1
    return max_date

print get_prophecy_date(raw_input(''))