import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Arrays;

public class TC
{
    static int[][][] cnt;
    static String s;
    static int[] days = { 31,28,31,30,31,30,31,31,30,31,30,31};
    
    static void solve() throws IOException
    {
        BufferedWriter out = new BufferedWriter( new OutputStreamWriter(System.out));
        cnt = new int[3][12][33];
        
        for( int[][] a:cnt)
            for(int[] b:a)
                Arrays.fill( b,0);
        
        String[] el=s.split("-");
        int ct=0;
        
        BigInteger aa,bb,cc;
        
        while( true )
        {
            if( el[ct++].length() == 0 )
                continue;
            
            aa = new BigInteger( el[ct-1]);
            
            if( el[ct++].length() == 0 )
                continue;
            
            bb = new BigInteger( el[ct-1]);
            
            if( el[ct++].length() == 0 )
                continue;
            
            cc = new BigInteger( el[ct-1]);
            
            break;
        }
        
        /*int aa = Integer.parseInt( el[ct++]);
        int bb= Integer.parseInt( el[ct++]);
        int cc= Integer.parseInt( el[ct++]);
        //0012-10-2013-10-2013 */
       // System.out.println(aa+" "+bb+" " +cc);
        int MAX = -1;
        int dd=0,mm=0,yy=0;
        BigInteger _100=new BigInteger("100");
        BigInteger _1=new BigInteger("1");
        BigInteger _12=new BigInteger("12");
        for( int i=0; i<el.length; )
        {
            
            BigInteger a=aa.mod(_100);
            BigInteger b=bb;
            BigInteger c;
            
            if( cc.toString().length() >=5 )
                c=new BigInteger( cc.toString().substring(0, 4));
            
            else
                c=new BigInteger( cc.toString());
            
            //while(c>=10000)
              //  c=c/10;
            
            if(( c.intValue() >= 2013 )&& (c.intValue() <= 2015 ))
            {
                int yr=c.intValue()-2013;
                
                if( ( b.compareTo(_1) >=0) && ( b.compareTo(_12)<=0 ))
                {
                    int MAXdays = days[b.intValue()-1];
                    if(( a.intValue()>=1)&&(a.intValue()<=MAXdays))
                    {
                        cnt[yr][b.intValue()-1][a.intValue()-1]++;
                        
                        if( cnt[yr][b.intValue()-1][a.intValue()-1] > MAX)
                        {
                            MAX = cnt[yr][b.intValue()-1][a.intValue()-1];
                            dd=a.intValue();
                            mm=b.intValue();
                            yy=yr+2013;
                        }
                    }
                            
                }
            }
            
            if( ct>=el.length )
                break;
            
            aa = bb;
            bb=cc;
            
            if( el[ct++].length() != 0 )
            {
                cc= new BigInteger( el[ct-1]);
                continue;
            }
            
            while( ct < el.length )
            {
                if( ct>=el.length )
                break;
            if( el[ct++].length() == 0 )
                continue;
            
            aa = new BigInteger( el[ct-1]);
            
            if( ct>=el.length )
                break;
            if( el[ct++].length() == 0 )
                continue;
            
            bb = new BigInteger( el[ct-1]);
            
            if( ct>=el.length )
                break;
            if( el[ct++].length() == 0 )
                continue;
            
            cc = new BigInteger( el[ct-1]);
            
            break;
            }
            
            if( ct>=el.length)
                break;
        }
        
        
        if( dd<10 )
            out.write("0" + Integer.toString( dd )+"-");
        else
            out.write(Integer.toString( dd )+"-");
        
        if( mm<10 )
            out.write("0" + Integer.toString( mm )+"-");
        else
            out.write(Integer.toString( mm )+"-");
        
        out.write(Integer.toString(yy)+"\n");
        out.close();
        
    }
    public static void main( String[] args ) throws IOException
    {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ));
        
        s=br.readLine();
        solve();
    }
}