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=""

A=[i.split("-") for i in set(ANS)]

for i in A:
    a,b,c = i; 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
    cc=ANS.count(i)
    if MAX < cc:
        ans = i
        MAX = cc

print ans