import re

#match dd-mm-yyyy
def isYun(year):
    if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
        return True
    return False

pattern = re.compile(r'\d{2}-\d{2}-\d{4}')
strp = raw_input()
st = {}
m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(0, len(strp) - 9):
    temp = strp[i:i + 10]
    matchs = pattern.match(temp)
    if matchs:
        day = int(temp[0:2])
        month = int(temp[3:5])
        year = int(temp[6:10])
        if year >= 2013 and year <= 2015 and month >= 1\
                and month <= 12 and day >= 1 and day <= 31:
            if m[month - 1] >= day:
                if st.has_key(temp):
                    st[temp] += 1
                else:
                    st[temp] = 1
            pass
        pass
tag = 0
ans = ""
for key in st.keys():
    if tag < st[key]:
        tag = st[key]
        ans = key
print ans
