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

public class Main{
    static int months[] = { 0 , 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 , 31 };
    static int gcd( int a , int b )
    {
        if( a < 1 )
            return b;
        return gcd( b % a , a );
    }
    public static boolean isLeap( int year )
    {
        if(  ( year % 100 == 0 & year % 400 == 0 ) || ( year % 100 != 0 && year % 4 == 0 ) )
        {
            return true;
        }
        return false;
    }
    public static String getValidDate( String d, String m, String year )
    {
        try
        {
            int pre = Integer.parseInt(year);
            int yr = Integer.parseInt(year.substring( year.length() - 4 , year.length()));
            if( pre != yr )
            {
                return null;
            }
            pre = Integer.parseInt(m);
            int mnt = Integer.parseInt(m.substring( m.length() - 2 , m.length()));
            if( pre != mnt || mnt < 1 || mnt > 12 )
            {
                return null;
            }
            int dy;
            if( isLeap(yr) && mnt == 2 )
            {
                dy = getDay( d, 28 );
            }
            else {
                dy = getDay( d, months[mnt] );
            }
            if( dy == -1 )
            {
                return null;
            }
            return appendZero(Integer.toString(dy) , 2) + '-' + appendZero(Integer.toString(mnt) , 2) + '-' + appendZero(Integer.toString(yr) , 4);
        }
        catch (Exception e)
        {
            return null;
        }

    }
    static String appendZero( String s, int cnt )
    {
        if( s.length() == cnt )
        {
            return s;
        }
        int d = cnt - s.length();
        while( d < cnt )
        {
            s = '0' + s;
            d++;
        }
        return s;
    }
    public static int getDay( String d , int limit )
    {
        int day = -1, temp = 0;
        int i = 0;
        while ( day == -1 && i < d.length() )
        {
            int t = Integer.parseInt( d.substring(i) );
            if( t > 0 && t <= limit )
            {
                day = t;
            }
            i++;
        }
        return day;
    }
    public static void main(String args[])
    {
        MyScanner scanner = new MyScanner();
        HashMap<String, Integer> map  = new HashMap<String, Integer>();
        String str = scanner.nextLine();
        int i = 0;
        String month = "" , day = "", year = "";
        StringBuilder s = new StringBuilder("");
        int d = -1 , m = -1, y = -1, last = -1;
         while ( i < str.length() )
         {
             if( str.charAt(i) == '-' )
             {
                 if( day.equals("") )
                 {
                     day = s.toString();
                     s = new StringBuilder();
                 }
                 else if( month.equals("") )
                 {
                     month = s.toString();
                     s = new StringBuilder();
                 }
                 else{
                     year = s.toString();
                     String date = getValidDate( day, month, year);
                     if( date!= null )
                     {
                         if( map.containsKey(date) )
                         {
                             map.put( date, map.get(date) + 1);
                         }
                         else{
                             map.put( date, 1 );
                         }
                     }
                     day = year;
                     month = "";
                     s = new StringBuilder();
                 }
             }
             else{
                 s.append( str.charAt(i) );
             }
             i++;
         }
        String finalDate = "";
        int cnt = 0;
        for( String date : map.keySet() )
        {
            int t = map.get(date);
            if( t > cnt )
            {
                finalDate = date;
            }
        }
        System.out.println(finalDate);

    }

}

class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public int mod(long x) {
        // TODO Auto-generated method stub
        return (int) x % 1000000007;
    }

    public int mod(int x) {
        return x % 1000000007;
    }

    boolean hasNext() {
        if (st.hasMoreElements())
            return true;
        try {
            st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return st.hasMoreTokens();
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
    public int[] readIntArray( int n )
    {
        int ar[] = new int[ n ];
        for( int i = 0;  i < n ; i++ )
            ar[ i ] = this.nextInt();
        return ar;
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
}