import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * Created by jizhe on 2016/1/5.
 */
public class AncientProphesy {
    private static int search(String pattern, int pStart, String text, int tStart) {
        int M = pattern.length();
        int N = text.length();
        int i, j;
        for (i = tStart, j = pStart; i < N && j < M; i++) {
            if ((pattern.charAt(j) != '-' && text.charAt(i) != '-') || (pattern.charAt(j) == '-' && text.charAt(i) == '-')) {
                j++;
            } else {
                i -= j;
                j = 0;
            }
        }

        if (j == M) {
            return i - M;
        } else {
            return N;
        }
    }

    private static boolean validDayMonth(int day, int month)
    {
        if( day < 1 && day > 31 )
        {
            return false;
        }

        if( month == 2 )
        {
            if( day > 28 )
            {
                return false;
            }
        }

        if( month == 4 || month == 6 || month == 9 || month == 11 )
        {
            if( day > 30 )
            {
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));

        String s = in.next();

        String[] dates = new String[20000];
        int[] stat = new int[20000];
        int count = 0;

        String pattern = "dd-mm-yyyy";
        for( int i = 0; i < s.length(); i++ )
        {
            i = search(pattern, 0, s, i);
            if( i == s.length() )
            {
                break;
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                int j = 0;
                while( j != 10 )
                {
                    sb.append(s.charAt(i+j));
                    j++;
                }
                String date = sb.toString();
                int day = 10*(date.charAt(0)-'0')+date.charAt(1)-'0';
                int month = 10*(date.charAt(3)-'0')+date.charAt(4)-'0';
                int year = 1000*(date.charAt(6)-'0')+100*(date.charAt(7)-'0')+10*(date.charAt(8)-'0')+date.charAt(9)-'0';
                //System.out.printf("%s\n", date);

                if( year < 2013 || year > 2015 )
                {
                    continue;
                }
                if( !validDayMonth(day, month) )
                {
                    continue;
                }

                int k;
                for( k = 0; k < count; k++ )
                {
                    if( dates[k].compareTo(date) == 0 )
                    {
                        break;
                    }
                }
                if( k == count )
                {
                    dates[count] = date;
                    stat[count++] = 1;
                }
                else
                {
                    stat[k]++;
                }
            }
        }

        int max = Integer.MIN_VALUE, maxIndex = 0;
        for( int i = 0; i < count; i++ )
        {
            //System.out.printf("%s, count: %d\n", dates[i], stat[i]);
            if( stat[i] > max )
            {
                max = stat[i];
                maxIndex = i;
            }
        }

        System.out.printf("%s\n", dates[maxIndex]);
    }
}
