import java.util.*;
import java.io.*;
import java.util.regex.*;

public class MainB {

    public static void main(String[] args) throws Exception {
    	String pattern = "\\d{2}-\\d{2}-\\d{4}";
    	BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
    	String line = buffer.readLine();
    	Pattern p = Pattern.compile(pattern);
    	Matcher m = p.matcher(line);
    	TreeMap<String, Integer> map = new TreeMap<String, Integer>();
    	while(m.find()) {
    		String temp = m.group();
    		if(!(temp.substring(6).equals("2013") || temp.substring(6).equals("2014") || temp.substring(6).equals("2015")))
    			continue;
    		int month = Integer.parseInt(temp.substring(3, 5));
    		if(month <= 0 || month > 12)
    			continue;
    		int day = Integer.parseInt(temp.substring(0, 2));
    		if(month == 2)
    			if(day <= 0 || day > 28)
    				continue;
    		if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    			if(day <= 0 || day > 31)
    				continue;
    		if(month == 4 || month == 6 || month == 9 || month == 11)
    			if(day <= 0 || day > 30)
    				continue;
    		if(map.containsKey(temp))
    			map.put(temp, map.get(temp)+1);
    		else
    			map.put(temp, 1);
    	}
    	System.out.println(map.firstKey());
    }
}
