import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

    static class node implements Comparable<node> {
        int n;
        int sum;

        @Override
        public int compareTo(node o) {
            return this.n - o.n;
        }

    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        String s = br.readLine();
        int[] date = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        StringBuilder x = new StringBuilder();

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '-') {
                if (i > 0 && s.charAt(i - 1) == '-') {
                    continue;
                } else {
                    x.append(s.charAt(i));
                }
            } else {
                x.append(s.charAt(i));
            }
        }
        String[] sp = x.toString().split("-");

        HashMap<String, Integer> h = new HashMap<String, Integer>();
        int max = 0;
        String maxS = "";
        for (int i = 0; i < sp.length; i++) {
            if (sp[i].length() >= 4) {
                String t = sp[i].charAt(0) + ""+  sp[i].charAt(1) + ""+ sp[i].charAt(2) + ""+ sp[i].charAt(3);
                int curr = Integer.parseInt(t);
                if (i >= 2 && curr >= 2013 && curr <= 2015 && sp[i - 1].length() <= 2) {
                    int m = Integer.parseInt(sp[i - 1]);
                    if (m > 0 && m <= 12 ) {
                        String temp = "";
                        if(sp[i-2].length() >=2){
                            temp +=  sp[i-2].charAt(sp[i-2].length() - 2);
                        }
                        
                            temp += sp[i-2].charAt(sp[i-2].length() - 1);
                            int currD = Integer.parseInt(temp);
                            int d = currD % 10;
                            currD /= 10;
                            d += ((currD % 10) * 10);
                            if (d <= date[m - 1] && d > 0) {
                                String c ="";
                                if(d < 10){
                                    c += "0" + d;
                                }else
                                    c += d;
                                
                                if(m < 10){
                                    c += "-0" + m;
                                }else
                                    c += "-" + m;
                                
                                c += "-" + curr;
                                if (h.containsKey(c)) {
                                    int y = h.get(c);
                                    h.remove(c);
                                    h.put(c, y + 1);
                                } else {
                                    h.put(c, 1);
                                }
                                int y = h.get(c);
                                if (max < h.get(c)) {
                                    max = h.get(c);
                                    maxS = c;
                                }
                            }
                        
                    }

                }
            }
        }
        System.out.println(maxS);
         System.out.print(out);
    }
}