days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def pattern(s):
	for i in [0, 1, 3, 4, 6, 7, 8, 9]:
		if s[i] < '0' or s[i] > '9':
			return False
	for i in [2, 5]:
		if s[i] != '-':
			return False
	return True

def extract(s):
	return map(int, [s[:2], s[3:5], s[6:]])

s = raw_input()
d = {}
for i in xrange(len(s)-9):
	p = s[i:i+10]
	if not pattern(p): continue
	dd, mm, yy = extract(p)
	if yy < 2013 or yy > 2015: continue
	if mm < 1 or mm > 12: continue
	if dd < 1 or dd > days[mm-1]: continue
	d[p] = 1 if p not in d else d[p] + 1
print sorted(zip(d.values(), d.keys()))[-1][1]
