#include <iostream>
#include <cstdio>
#include <conio.h>
#include <string.h>
#include <vector>
#include <string>
#include <cmath>
#include <cctype>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <cmath>

using namespace std;
bool cek(string temp){
	string month = temp.substr(3,2);
	int m = atoi(month.c_str());
	string day = temp.substr(0,2);
	int d = atoi(day.c_str());
	string year = temp.substr(6,4);
	int y = atoi(year.c_str());
	int md[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
	if(d > md[m]){
		return false;
	} 
	else if(y > 2015 || y < 2013) return false;
	return true;
}
int main()
{
    //freopen("input.txt","r",stdin);
   	map<string,int> mp;
   	map<string,int>::iterator it;
   	bool flag;
   	string in;
   	int m =0;
   	getline(cin,in);
   	for(int i=0;i<=in.length()-10;i++){
		string temp = in.substr(i,10);
		flag = true;flag = cek(temp);
		for(int i=0;i<temp.length();i++){
			if(i == 2 || i == 5){
				if(!ispunct(temp[i])){
					flag = false; break;
				}	
			}
			else{
				if(!isdigit(temp[i])){
					flag = false; break;
				}
			}
		}
		
		if(flag == true){
			if(mp.find(temp) == mp.end()){
				mp.insert(pair<string,int>(temp,1));
				m = max(m,mp[temp]);
			}
				
			else{
				mp[temp]++;
				m = max(m,mp[temp]);
			}
		}
		
   	}
   	for(it=mp.begin();it!=mp.end();it++){
		if((*it).second == m){
			cout << (*it).first; break;
		}
   	}
    return 0;
}