import re

s = raw_input()

mon = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
mp = {}
date = []

for i in xrange(len(s) - 9):
    if re.match(r'\d{2}-\d{2}-\d{4}', s[i : i + 10]) != None:
        date += [s[i : i + 10]]

for day in date:
    [d, m, y] = map(int, day.split('-'))
    if y >= 2013 and y <= 2015 and m >= 1 and m <= 12 and d <= mon[m - 1] \
            and d >= 1:
                mp[day] = 1 if mp.has_key(day) == False else mp[day] + 1

mx = max(mp.values())
for key in mp:
    if mp[key] == mx:
        print key
        exit()
