import re

tveebi = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ANS = re.findall("(?=([0-9][0-9]-[0-9][0-9]-201[345]))", raw_input ())
LEQ={}
MAX = -1
ans=""

for i in ANS:
    a,b,c = i.split ("-"); a = int(a); b = int(b); c = int(c);
    if (c<2013 or c>2015 or b<1 or b>12 or a<1 or a>tveebi[b]): continue
    if LEQ.has_key(i):
        LEQ[i]+=1
        if MAX < LEQ[i]:
            ans = i
            MAX = LEQ[i]
    else:
        LEQ[i] = 0

print ans