#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string date1, date2, date3;
char a[3], b[3], c[3];
vector<string> date;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
bool f(int x)
{
if((x % 4 == 0 && x % 100 != 0))
return true;
return false;
}
bool solve(int t1, int t2, int t3, string &date, char a[], char b[], char c[])
{
if(t2 >= 1 && t2 <= 12 && t3 >= 1 && t3 <= 31)
{
bool flag = true;
if(t1 >= 0 && t1 <= 59)
{
if(!f(2000 + t1)) flag = false;
}
else if(!f(1900 + t1)) flag = false;
if(t2 == 2)
{
if(flag && t3 > 29) return false;
if(!flag && t3 > 28) return false;
}
if(t2 != 2 && t3 > days[t2]) return false;
if(t1 >= 0 && t1 <= 59) date = "20";
else date = "19";
date += a[0];
date += a[1];
date += '-';
date += b[0];
date += b[1];
date += '-';
date += c[0];
date += c[1];
return true;
}
return false;
}
int main()
{
scanf("%s/%s/%s",a, b, c);
int t1 = (a[0] - '0') * 10 + a[1] - '0';
int t2 = (b[0] - '0') * 10 + b[1] - '0';
int t3 = (c[0] - '0') * 10 + c[1] - '0';
//年月日
if(solve(t1, t2, t3, date1, a, b, c)) date.push_back(date1);
//月日年
if(solve(t3, t1, t2, date2, c, a, b)) date.push_back(date2);
//日月年
if(solve(t3, t2, t1, date3, c, b, a)) date.push_back(date3);
sort(date.begin(), date.end());
for(int i = 0; i < date.size(); i ++)
if(i != date.size() - 1 && date[i] == date[i + 1]) continue;
else
cout << date[i] << endl;
return 0;
}