
import sys
line = sys.stdin.readline().strip()

days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def check(s):
    d, s1, m, s2, y = s[0:2], s[2], s[3:5], s[5], s[6:10]
    if str.isdigit(d) and s1 == '-' and str.isdigit(m) and s2 == '-' and str.isdigit(y):
        d = int(d)
        m = int(m)
        y = int(y)
        if 2013 <= y and y <= 2015:
            if 1 <= m and m <= 12:
                if 1 <= d and d <= days[m - 1]:
                    return True
    return False

apocalypse = {}
for i in xrange(0, len(line) - 9):
    sub = line[i:i+10]
    if check(sub):
        if sub in apocalypse:
            apocalypse[sub] += 1
        else:
            apocalypse[sub] = 1

print sorted(apocalypse.items(), key=lambda x:-x[1])[0][0]
