import re
s = raw_input()
days = [31,28,31,30,31,30,31,31,30,31,30,31]
d= {}
for t in  re.findall("(?=([0-9]{2}\-[0-9]{2}\-[0-9]{4}))",s):
    day,month,year = map(int,t.split('-'))
    if (month > 12 or month <1): continue
    if (year<2013 or year>2015): continue
    if (day > days[month-1] or day == 0):continue
    if t not in d: d[t] = 0
    d[t] += 1

print d
print max(d,key = lambda x : d[x])
