import sys
import time
import re
s=sys.stdin.readline()
days = [0,31,28,31,30,31,30,31,31,30,31,30,31]
a=re.findall('(?=(\d\d-\d\d-\d\d\d\d))',s)
dict = {}
for x in a:
    t = map(int,x.split('-'))
    if t[2] < 2013 or t[2]  > 2015: continue
    if t[1] < 1 or t[1] > 12: continue
    if t[0] < 1 or t[0] > days[t[1]]: continue
    dict[x] = dict.get(x,0)+1
mx = max(dict.values())
for k in dict.keys():
    if dict[k] == mx:
        print k
        sys.exit()
