import datetime
s = raw_input()
result = {}
for i in xrange(len(s)-9):
    try:
        if s[i+2] != '-' or s[i+5] != '-':
            raise ValueError
        datetime.date(int(s[i+6:i+10]), int(s[i+3:i+5]), int(s[i:i+2]))
    except ValueError:
        continue
    if s[i:i+10] in result:        result[s[i:i+10]] += 1
    else:                          result[s[i:i+10]] = 1

if not result or result.values().count(max(result.values())) > 1:
    print -1
else:
    m = max(result.values())
    for i in result:
        if result[i] == m:            
            print i
            break
        
    
