import re
ANS = re.findall("(?=([0-3][0-9]-[01][0-9]-201[345]))", raw_input ())
def f(i):
    l = [int(p) for p in i.split ("-") if p!='00']
    return (l[1]<13 and l[0]<=[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][l[1]])
print sorted([(ANS.count(i),i) for i in set(ANS) if f(i)])[-1][1]