from re import *
from calendar import *
s = raw_input()
r = {}
for x in findall('(?=(\d\d-\d\d-201[3-5]))', s):
	d, m, y = map(int, x.split('-'))
	if 1 <= m <= 12 and 1 <= d <= monthrange(y, m)[1]:
		r[x] = r.get(x, 0) + 1
p = max(r.values())
for k, v in r.items():
	if v == p:
		print k