#!/usr/local/bin/python

s = raw_input().strip()

month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
map = {}
for i in xrange(len(s)-9):
	a = s[i:i+10]
	if not a[2] == '-' or not a[5] == '-': continue
	l = [x.strip() for x in a.split("-")]
	if not len(l) == 3: continue;
	d, m, y = [int(x) for x in l]
	if y >= 2013 and y <= 2015 and m >=1 and m <= 12 and d > 0 and d <= month[m-1]:
		if a in map:
			map[a]+=1
		else:
			map[a]=1

maxim, ans = 0, ""
for k, v in map.iteritems():
	if maxim < v:
		ans = k
		maxim = v;

print ans