s = list(raw_input())
r = {}
c = s[ : 10].count('-')
for i in range(len(s) - 9):
	if c == 2 and s[i + 2] == s[i + 5] == '-':
		d, m, y = map(int, [''.join(s[i : i + 2]), ''.join(s[i + 3 : i + 5]), ''.join(s[i + 6 : i + 10])])
		if 2013 <= y <= 2015 and 1 <= m <= 12 and 1 <= d <= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]:
			r[(d, m, y)] = r.get((d, m, y), 0) + 1
	if i + 10 != len(s):
		c += s[i + 10] == '-'
		c -= s[i] == '-'
b = max(r.values())
for i, v in r.items():
	if v == b:
		print '%02d-%02d-%d' % (i[0], i[1], i[2])