import sys # sys.exit() quit()
readln = lambda: map(int, raw_input().split())
#sys.stdin = open('input.txt','r'); sys.stdout = open('output.txt','w')
# graph: G = [[] for _ in xrange(NMAX)]
# v=[];[v.append(raw_input().split()) for i in xrange(n)]
# print x, #no endl

s = raw_input()
occ = {}
for i in xrange(len(s)-9):
    date = s[i:i+10]
    #print date[6:10]
    year = date[6:10]
    month = date[3:5]
    day = date[0:2]
    if year in ["2013","2014","2015"]\
    and date[2] == "-" and date[5] == "-"\
    and int(month)>=1 and int(month)<=12\
    and int(day)>0 and int(day)<=31:
        if month == "02" and day>28:
            continue
        if month in ["04","06","09","11"] and day>30:
            continue
        if date not in occ:
            occ[date]=1
        else: occ[date]=1+occ[date]
print max(occ)
