import re

tveebi = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
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]<=tveebi[l[1]])

t=[(ANS.count(i),i) for i in set(ANS) if f(i)]
t.sort()
print t[-1][1]