import re;
match = re.findall('(?=(\d\d-\d\d-\d\d\d\d))',raw_input())
day=[0,31,28,31,30,31,30,31,31,30,31,30,31]
t,ans,mp=0,'',{}
for ch in match:
	d,m,y=map(int,ch.split('-'))
	if 2013<=y<=2015 and 1<=m<=12 and 1<=d<=day[m]:
		mp[ch] = (mp.get(ch) or 0) + 1
print max(mp.iteritems(),key=lambda x:x[1])[0]
