#!/usr/bin/env python
import re as regex
numdays = [0, 32, 29, 32, 31, 32, 31, 32, 32, 31, 32, 31, 32]
def validDate(Date):
    Date = map(int, Date.split("-"))
    return 0 < Date[0] < numdays[Date[1]]
    
G = regex.findall("(?=([0123]\d-(0\d|1[012])-201[3-5]))", raw_input())
print max((G.count(H), H[0]) for H in {}.fromkeys(G).keys() if validDate(H[0]))[1]