#!/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]
    
G = regex.findall("(?=([0123]\d-(0\d|1[012])-201[3-5]))", raw_input())
SET = {}.fromkeys(G).keys()
print max((G.count(H), H[0]) for H in SET if validDate(int(H[0][:2]), int(H[0][3:5])))[1]