import re

def c(d):
    d,m,y=map(int,d.split('-'))
    M=set([1,3,5,7,8,10,12])
    return y > 2012 and y< 2016 and (d<29 and m==2 or d<31 and m in M or d<32 and m in (set(range(4,13))-M))
    
    
d=re.findall("(?=(\d\d-\d\d-\d{4}))", raw_input())
r={}
for i in d:
    r[i]=r.get(i,0)+c(i)
print max(r.items(), key=lambda y:y[1])[0]
