###########################

from sys import stdin
di = {}
pos = [0,31,28,31,30,31,30,31,31,30,31,30,31]
a= stdin.readline().strip()
def valid(x):
	#print "from ",x
	x = x.split('-')
	if len(x)!=3:
		return 0
	d,m,y = x
	#print "date ",d,m,y
	if len(d)!=2:
		return 0
	if len(m)!=2:
		return 0
	if len(y)!=4:
		return 0
	if d[0]=='0':
		d = d[1:]
	d=int(d)
	if m[0]=='0':
		m=m[1:]
	if y[0]=='0':
		y=y[1:]
	if y[0]=='0':
		y=y[1:]
	if y[0]=='0':
		y=y[1:]
	m=int(m)
	y=int(y)
	#print "till now ",d,m,y
	if y>2015:
		return 0
	if y<2013:
		return 0
	if m>12:
		return 0
	if m<1:
		return 0
	if d<1:
		return 0
	if d>pos[m]:
		return 0
	return 1
	
l = len(a)
for i in xrange(l-9):
	b = a[i:i+10]
	if valid(b):
		di[b] = di.get(b,0)+1
ans = ''
co = 0
for i in di:
	if di[i] > co:
		co = di[i]
		ans = i
print ans