import re

tveebi = [30 + i%2 for i in range(13)]; tveebi[2]=28

ANS = re.findall("(?=([0-9][0-9]-[0-9][0-9]-201[345]))", raw_input ())
MAX = -1
ans=""

for i in set(ANS):
    l = [int(p) for p in i.split ("-")]
    if (not 2012<l[2]<2016 or not 0<l[1]<13 or not 0<l[0]<=tveebi[l[1]]): continue
    cc=ANS.count(i)
    if MAX < cc:
        ans = i
        MAX = cc

print ans