s=raw_input()
MAP={}
M=[31,28,31,30,31,30,31,31,30,31,30,31]
def f(s):
    l=s.split('-')
    if len(l)!=3 or len(l[0])<2 or len(l[1])<2 or len(l[2])<4:
        return 0
    d=int(l[0])
    m=int(l[1])
    y=int(l[2])
    if y<2013 or y>2015 :
        return 0
    if m<1 or m>12 :
        return 0
    if d<1 or d>M[m-1]:
        return 0
    return 1
ma=0
res=''
for i in range(len(s)-10+1):
    s2=s[i:i+10]
    #print s2
    if f(s2):
        if s2 in MAP:
            MAP[s2]+=1
        else:
            MAP[s2]=1
        if MAP[s2]>ma:
            ma=MAP[s2]
            res=s2
print res
