import java.util.*;
import java.io.*;
/**
 *
 * @author mohanad
 */
public class Div2_260B {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();
        String ans []={"00" , "-" , "00" , "-" , "0000"};
        
        int len = s.length();
        int i =  0;
        String monrtLen [] = {"00" , "31" , "28" , "31" , " 30" , " 31" , "30" , "31" , "31" , "30" , "31" , "30" , "31"};
        while (i<len-10){
            
            
            String date = s.substring(i , i+10);
            char [] charDate=date.toCharArray();
            
            String yyyy , mm , dd;
            if (charDate.length<10 || charDate[2]!='-' || charDate[5]!='-'){
                ++i;
                continue;
            }
            yyyy=charDate[6]+""+charDate[7]+""+charDate[8]+""+charDate[9];
            if (charDate[6]=='-' || charDate[7]=='-'  || charDate[8]=='-' || charDate[9]=='-' || yyyy.compareTo("2013")<0 || 
                   yyyy.compareTo("2015")>0  ){
                ++i;
                continue;
            }
            
            mm=charDate[3]+""+charDate[4];
            if (charDate[3]=='-' || charDate[4]=='-'  || mm.compareTo("00")<=0 || mm.compareTo("12")>0){
                ++i;
                continue;
            }
            
           
            String monthl;
            if (charDate[3]=='0')
                monthl=monrtLen[charDate[3]-'0'];
            else 
                monthl=monrtLen[Integer.parseInt(mm)];
             
            dd=charDate[0]+""+charDate[1];
            
            if (charDate[0]=='-' || charDate[1]=='-'  || dd.compareTo(monthl)>0 || dd.compareTo("00")<=0){
                ++i;
                continue;
            }
            
            if (dd.compareTo(ans[0])>=0 && mm.compareTo(ans[2])>=0 || yyyy.compareTo(ans[4])>=0){
                ans[0]=dd;
                ans[2] = mm;
                ans[4] = yyyy;
            }
            ++i;
        }
        
        for (String a : ans)
            System.out.print(a);
    }
    
}
