/*
*年份组合:
*范围:1960年1月1日至2059年12月31日
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int da[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int a, b, c;// a / b / c, c / a / b, c / b / a
vector<string> v;
void check(int y, int m, int d)
{
if (y <= 59) y = 2000 + y;//检查年
else y += 1900;
da[2] = ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) ? 29 : 28;//更新2月信息
if (m > 13) return ;//检查月
if (d > da[m] || d <= 0) return ;//检查日
string s = "";
while (y){
s += y % 10 + '0';
y /= 10;
}
reverse(s.begin(), s.end());
s += '-';
s += m / 10 + '0';
s += m % 10 + '0';
s += '-';
s += d / 10 + '0';
s += d % 10 + '0';
v.push_back(s);
}
int main()
{
scanf("%d/%d/%d", &a, &b, &c);
check(a, b, c);
check(c, a, b);
check(c, b, a);
sort(v.begin(), v.end());
for (int i = 0; i < (int)v.size(); i ++ )
if (i == 0 || v[i] != v[i - 1])//日期重复不应输出
cout << v[i] << '\n';
return 0;
}