import re
stri = raw_input ()
tveebi = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def MAX(L, year):
    Lnew=[]
    for line in L:
        a,b,c = line.split ("-")
        a, b = int(a), int(b)

        if (a>0 and b>0 and b<=12 and a<=tveebi[b]):
            Lnew.append((a,b))
    Lnew.sort()
    if (len(Lnew)==0):
        return -1,-1

    MAX = 1
    counter=1
    ans=str(Lnew[0][0]).zfill(2)+"-"+str(Lnew[0][1]).zfill(2)+"-"+c

    aa, bb = Lnew[0]
    for i in range(1, len(Lnew)):
        if (Lnew[i][0] == aa and Lnew[i][1] == bb):
            counter+=1
            if (counter>MAX):
                ans = str(Lnew[i][0]).zfill(2)+"-"+str(Lnew[i][1]).zfill(2)+"-"+c
                MAX = counter
        else:
            counter=1
        aa, bb = Lnew[i][0], Lnew[i][1]
    #print ans, MAX
    return ans, MAX
        
            

_13 = re.findall("(?=([0-9][0-9]-[0-9][0-9]-2013))", stri)
_14 = re.findall("(?=([0-9][0-9]-[0-9][0-9]-2014))", stri)
_15 = re.findall("(?=([0-9][0-9]-[0-9][0-9]-2015))", stri)
    

_13_ans, _13_ = MAX(_13, 13)
_14_ans, _14_ = MAX(_14, 14)
_15_ans, _15_ = MAX(_15, 15)


if (_13_>_14_ and _13_>_15_):
    print _13_ans
if (_14_>_13_ and _14_>_15_):
    print _14_ans
if (_15_>_14_ and _15_>_13_):
    print _15_ans