dates = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def is_valid(s):
    try:
        month, day = int(s[3:5]), int(s[:2])
    except Exception:
        return False

    return (
        s[2] == s[5] == '-' and
        s[6:] in ['2013', '2014', '2015'] and
        month >= 1 and 
        month <= 12 and 
        day >= 1 and 
        day <= dates[month - 1])

def main():
    s = raw_input()
    n = len(s)
    index = {}

    for i in xrange(n - 10):
        data = s[i:i+10]
        if is_valid(data):
            index[data] = index.get(data, 0) + 1

    date = None
    for k in index:
        if date is None or index[k] > index[date]:
            date = k
    print date


if __name__ == '__main__':
    main()
