s = raw_input()
a = s.split('-')
days=[-1, 31,28,31,30,31,30,31,31,30,31,30,31]
d,m,y=0,0,0; best = 0
for i in range(1, 32):
    for j in range(1, 13):
        if days[j] < i: continue
        for k in range(2013, 2016):
            amo = 0
            for it in range(len(a)-2):
                l1=len(str(i)); l2=len(str(j)); l3=4
                f=str(i); b =str(j); c=str(k)
                if len(f)<2:f='0'+f; l1=len(f);
                if len(b)<2:b='0'+b; l2=len(b)
                if a[it][len(a[it])-l1:]==f and a[it+1]==b and a[it+2][:l3]==c:
                    amo+=1
                #if i == 13 and j == 10 and k == 2013: print(amo)
            if amo > best:
                d,m,y=i,j,k
                best = amo
print(str(d)+'-'+str(m)+'-'+str(y))
