import re
from sys import stdin


def occurrences(string, sub):
    count = start = 0
    while True:
        start = string.find(sub, start) + 1
        if start > 0:
            count+=1
        else:
            return count

data = [30,28,31,30,31,30,31,31,30,31,30,31]
table = {}
text = stdin.readline()
for i in range(len(text)) :
    m = re.match("[0-9]{2}-[0-9]{2}-[0-9]{4}", text[i:])
    if m is not None :
        k = m.group()
        if  k not in table :
            table[k] = 1
        else :
            table[k] += 1

max_count = 0
res = None
for x in table :
    d,m,y = x.split('-')
    if 2013 <= int(y) <= 2015 and 1 <= int(m) <=12 and int(d) > 0 and int(d) <= data[int(m) - 1] and table[x] > max_count :
        max_count = table[x]
        res = x

print res
