#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<string> split(string s, string c) {
  vector<string> ret;
  for (int i = 0, n; i <= s.length(); i = n + 1) {
    n = s.find_first_of(c, i);
    if (n == string::npos) n = s.length();
    string tmp = s.substr(i, n - i);
    ret.push_back(tmp);
  }
  return ret;
}
string last2(string s) {
  if (s.size() < 3) {
    return s;
  } else {
    return s.substr(s.size() - 2, s.size() - 1);
  }
}
string fast4(string s) {
  if (s.size() < 5) {
    return s;
  } else {
    return s.substr(0, 3);
  }
}
int main() {
  string str;
  cin >> str;
  str = "0-0-" + str;
  vector<string> strs = split(str, "-");
  set<string> data;
  int m, d;
  for (int i = (2); i <= (strs.size() - 1); ++i) {
    string fast = fast4(strs[i]);
    string last = last2(strs[i - 2]);
    switch (toInt(fast)) {
      case 2013:
      case 2014:
      case 2015:
        if (strs[i - 1].size() == 2) {
          m = toInt(strs[i - 1]);
          if (0 < m && m < 13) {
            d = toInt(last);
            if (0 < d && d <= day[m]) {
              string tmp = last + "-" + strs[i - 1] + "-" + fast;
              if (data.find(tmp) != data.end()) {
                cout << tmp << endl;
                return 0;
              } else {
                data.insert(tmp);
              }
            }
          }
        }
        break;
      default:
        break;
    }
  }
  cout << -1 << endl;
  return 0;
}
