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

public class apocalypse{
    public static void main (String args[]) throws IOException
    {
        int c,d=0,temp=0,i=0,j=0,n,value=0,index=0;
        String st,dash; 
        ArrayList <String>date = new ArrayList <String>();
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = br.readLine();
        n= st.length();
        int count[] = new int[n];
        for(i=0;i<n;i++)
        {
            count[i]=0;
        }
    
        for(i=6;i<n-3;i++)
        {
            dash = st.substring(i,i+4);
            if(dash.equals("2012")||dash.equals("2013")||dash.equals("2014")||dash.equals("2015"))
            {
                dash = st.substring(i-6,i+4);
                if(isValid(dash))
                {
                    if(date.size()==0)
                    {
                        date.add(dash);
                        value =1;
                    }
                    else
                    {
                        value =0;
                        d= date.size();
                        for(j=0;j<d;j++)
                        {
                            if(date.get(j).equals(dash))
                            {
                                c = count[j];
                                count[j]=c+1;
                                value = 1;
                                break;
                            }
                        }
                    }
                    if(value !=1)
                    {
                        date.add(dash);                 
                    }
                }
            }
        }
        for(i=0;i<n;i++)
        {
            if(count[i]>temp)   {
                index =i;   temp=count[i];
            }
        }
        
        System.out.println(date.get(index));
        
    }
    private static boolean isValid(String str)
    {
        int day,mon;
        try
        {
            day = Integer.parseInt(str.substring(0,2));
            mon = Integer.parseInt(str.substring(3,5));
            if((mon%2==1)&&(0<= day && day<=31))
                return true;
            else if((mon ==2)&&(0<= day && day<=28))
                return false;
            else if((mon%2==0)&&(0<= day && day<=31))
                return true;
            else return false;
        }
        catch(Exception e){return false;}
    } 
}