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

cnt = {}
s = raw_input()
i = 0
while i + 10 <= len(s):
    p = s[i:i+10]
    if p[2] == '-' and p[5] == '-':
        try:
            day = int(p[:2])
            month = int(p[3:5])
            year = int(p[6:])
        except ValueError:
            pass
        else:
            if 2013 <= year <= 2015 and 1 <= month <= 12 and 1 <= day <= days[month-1]:
                e = (day, month, year)
                if e not in cnt:
                    cnt[e] = 1
                else:
                    cnt[e] += 1
    i += 1

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

print "{0:0>2}-{1:0>2}-{2:0>4}".format(res[0], res[1], res[2])
            
