import java.util.Scanner;
import java.util.StringTokenizer;

public class C {

    public static void main(String[] args) {
        int len[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

        Scanner myScanner = new Scanner(System.in);
        String input = myScanner.next().replaceAll("[-]", " ");
        StringTokenizer tok = new StringTokenizer(input);

        String all[] = new String[tok.countTokens()];
        for (int i = 0; i < all.length; i++)
            all[i] = tok.nextToken();

        int dates[] = new int[31 * 12 * 2015];
        int max = -1, md = 0, mm = 0, my = 0;

        for (int i = 0; i < all.length - 2; i++) {
            if (all[i + 2].length() < 4)
                continue;

            int n1 = all[i].length(), n2 = all[i + 1].length(), n3 = all[i + 2]
                    .length();

            int day = new Integer(all[i].substring(n1 - 2)), mon = new Integer(
                    all[i + 1].substring(n2 - 2)), year = new Integer(
                    all[i + 2].substring(n3 - 4));

            if (day > 1 && mon >= 1 && mon <= 12 && year >= 2013
                    && year <= 2015 && day <= len[mon]) {
                int ii;
                dates[(ii = day * mon * year)]++;
                if (dates[ii] > max) {
                    max = dates[ii];
                    md = day;
                    mm = mon;
                    my = year;
                }
            }
        }
        String sd = md + "";
        String sm = mm + "";

        if (sd.length() == 1)
            sd = '0' + sd;
        if (sm.length() == 1)
            sm = '0' + sm;

        System.out.println(sd + "-" + sm + "-" + my);
    }
}
