import re
s = raw_input()
x=re.findall("..-..-....",s)
ans={"asd":-1}
days= [0,31,28,31,30,31,30,31,31,30,31,30,31]
for i in x:
	day=i[:2]
	month = i[3:5]
	year = i[6:]
	#print i, day, month, year
	if (year >= "2013" and year <= "2015") and (month>"0" and month<"13") and (day>"0" and day < str(days[int(month)])) :
		if i in ans:
			ans[i]+=1
		else:
			ans[i]=1
max_cnt=0
max_ans=""
#print ans
for i in ans:
	if ans[i]>max_cnt:
		max_ans = i
		max_cnt = ans[i]

print max_ans