import re,calendar as d
o=[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([(o.count(i),i) for i in set(o) if f(i)])[1]