import re, calendar as d
ANS=[i[0] for i in re.findall("(?=([0-3][0-9]-(1[012]|0[1-9])-201[345]))", raw_input ())]
def f(i):
    a,b,c=i.split ("-")
    return 0<int(a)<=d.monthrange(int(c),int(b))[1]
print max([(ANS.count(i),i) for i in set(ANS) if f(i)])[1]