#!/usr/bin/env python
import re
import datetime

s = raw_input()
regex = re.compile('(((0[1-9]|[12]\d|3[01])-(0[13578]|1[02])-(201[3-5]))|((0[1-9]|[12]\d|30)-(0[13456789]|1[012])-(201[3-5]))|((0[1-9]|1\d|2[0-8])-02-(201[3-5])))')

date = None
for i in regex.findall(s):
        new = datetime.datetime.strptime(i[0], '%d-%m-%Y')
        if not date or new < date:
                date = new

print date.strftime('%d-%m-%Y')