import sys
import re


def main() :
    s = sys.stdin.readline().strip()
    freqs = {}
    finder = re.compile( "(\d\d)-(\d\d)-201(\d)" ) 
    days = [ 0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ]
    pos = 0
    posMax = len( s ) - 9 
    while pos < posMax :
        match = finder.search( s[ pos : pos + 10 ] )
        if match :
            matchI = [ int( x ) for x in match.groups() ]
            pos += 7
            if matchI[ 1 ] < 13 and matchI[ 0 ] <= days[ matchI[ 1 ] ] and matchI[ 0 ] > 0 and matchI[ 1 ] > 0 and matchI[ 2 ] >= 3 and matchI[ 2 ] <= 5 :
                if match.group() not in freqs :
                       freqs[ match.group() ] = 0
                freqs[ match.group() ] += 1
        pos += 1
    maxFreq = max( freqs.values() )
    dates = [ x for x in freqs if freqs[ x ] == maxFreq ]
    print dates[ 0 ]
    
        
    
        

if __name__ == "__main__" :
    main()
