import re,calendar as test

def solve(i):
    a , b , c = i.split("-")
    a , b , c = int(a), int(b), int(c)
    return 0 < a <= test.monthrange(c , b)[1]

arr = [i[0] for i in re.findall("(?=([0-3][0-9]-(1[012]|0[1-9])-201[345]))",raw_input())]

print max( [(arr.count(i), i) for i in set(arr) if solve(i) ])[1]
