'''
Created on Dec 31, 2012

@author: Evan
'''

def checkFormat(item):
    import re
    pat = r'[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'
    if re.match(pat, item):
        return True
    return False

def checkYear(item):
    if 2013 <= int(item) <= 2015:
        return True
    return False

def checkMonth(item):
    if 1 <= int(item) <= 12:
        month = int(item)
        return True
    return False
        
def checkDay(item):
    if 1 <= int(item) <= 28:
        return True
    elif int(item) == 29 or int(item) == 30:
        if month <= 12 and month != 2:
            return True
    elif int(item) == 31:
        if month == 1 or month == 3 or month == 5 or month == 7 or \
        month == 8 or month == 10 or month == 12:
            return True
    return False

month = 0
omen = raw_input()
prophesy = {}
for x in range(len(omen)-9):
    if (checkFormat(omen[x:x+10])):
        if (checkYear(omen[x+6:x+10])):
            if (checkMonth(omen[x+3:x+5])):
                if (checkDay(omen[x:x+2])):
                    if (prophesy.get(omen[x:x+10], 0) == 0):
                        prophesy[omen[x:x+10]] = 1
                    else:
                        prophesy[omen[x:x+10]] += 1
date = ""
maxcount = 0
for x in prophesy.keys():
    if prophesy[x] > maxcount:
        maxcount = prophesy[x]
        date = x
print date