#!/usr/bin/env python
import re as regex

def validDate(day, month):
    numdays = [0, 32, 29, 32, 31, 32, 31, 32, 32, 31, 32, 31, 32]
    return 0 < day < numdays[month]

MAX, MAXDAY = 0, ''
G = [ d.group(1) for d in regex.finditer("(?=([0123]\d-(0\d|1[012])-201[3-5]))", raw_input())]
for date in {}.fromkeys(G).keys():
    line = map(int, date.split("-"))
    if validDate(line[0], line[1]):
        c = G.count(date)
        if c > MAX:
            MAX = c
            MAXDAY = date
print MAXDAY