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]:
		if ch in mp:
			mp[ch]+=1
		else :
			mp[ch]=1
for ch in mp:
	if mp[ch] > t:
		t,ans=mp[ch],ch
print ans
