s=input()
def correct(s):
    if s[2]=="-" and s[5]=="-":
        pass
    else:
        return False
###check for day
    d1={"0","1","2","3"}
    if s[0] not in d1:
        return False
    elif s[0]=="3":
        if s[1]=="0" or s[1]=="1":
            pass
        else:
            return False
    elif s[0]=="0":
        if s[1]=="0":
            return False
    elif s[1]=="-":
        return False

##check for month
    if s[3]=="0" or s[3]=="1":
        if s[4]!="-":
            if s[3]=="1":
                if s[4]=="1" or s[4]=="2":
                    pass
                else:
                    return False
            else:
                if s[4]=="0":
                    return False
        else:
            return False
    else:
        return False

#check for year
    y={"2013","2014","2015"}
    if s[6:] not in y:
        return False
    if s[0:2]=="31":
        m={"01","03","05","07","08","10","12"}
        if s[3:5] not in m:
            return False
    return True


dict={}
n=len(s)
i=0
while i<=n-10:
    if correct(s[i:i+10])==True:
        if s[i:i+10] in dict:
            dict[s[i:i+10]]+=1
        else:
            dict[s[i:i+10]]=1
        i+=8
    else:
        i+=1
m=0
ans=None
for key,item in dict.items():
    if item>m:
        m=item
        ans=key
print(ans)
