import re


#line = "777-444---21-12-2013-12-2013-12-2013---444-777"
line = raw_input()
dictt={}

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

r=re.compile('\d\d-\d\d-\d\d\d\d')
while True:
	var= r.search(line)
	if(var==None):
		break
	out=str(var.group())
	
	dd=int(out[:2],10)
	mm=int(out[3:5],10)
	yy=int(out[6:],10)
	valid=1
	
	if(mm<1 or mm>12 or days[mm]<dd or dd<0):
		valid=0
	if(yy<2013 or yy>2015):
		valid=0
	
	if(valid==0):
		ind=line.find(out)
		line=line[ind+8:]
		continue	
	
	
	
	if(dictt.has_key(out)):
		dictt[out]+=1
	else:
		dictt[out]=1
	ind=line.find(out)
	line=line[ind+8:]
	#print out

#print dictt
out=""
maxi=-9
for x,y in dictt.items():
	if(y>maxi):
		maxi=y
		out=x
print out
