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 ())
MAX = -1
ans=""

for i in set(ANS):
    l = [int(p) for p in i.split ("-") if p!='0']
    if (l[1]>12 or l[0]>tveebi[l[1]]): continue
    cc=ANS.count(i)
    if MAX < cc:
        ans = i
        MAX = cc

print ans