#include <bits/stdc++.h>
using namespace std;
bool judge(string &s) {
  if (s[2] != '-' || s[5] != '-') return false;
  int day, month, year;
  day = (s[0] - '0') * 10 + (s[1] - '0');
  month = (s[3] - '0') * 10 + (s[4] - '0');
  year = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 +
         (s[9] - '0');
  int b[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (year < 2013 || year > 2015) return false;
  if (month < 1 || month > 12) return false;
  if (day < 0 || day > b[month]) return false;
  return true;
}
int main() {
  int n, i;
  string str, *s, result, temp;
  cin >> str;
  n = str.size();
  s = new string[n - 10];
  for (i = 0; i < n - 10; i++) {
    s[i] = str.substr(i, 10);
  }
  queue<string> s_que;
  for (i = 0; i < n - 10; i++) {
    if (judge(s[i])) s_que.push(s[i]);
  }
  result = s_que.front();
  s_que.pop();
  while (!s_que.empty()) {
    temp = s_que.front();
    s_que.pop();
    if (temp > result) result = temp;
  }
  cout << result << endl;
  return 0;
}
