#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, INF = 0x3f3f3f3f, mod = 1000000007;
string s, mxs;
int mxd = 0, dp[maxn];
const int dy[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int trnNum(string s) {
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    ans = ans * 10 + s[i] - '0';
  }
  return ans;
}
inline int tYtN(string s) {
  return (trnNum(s.substr(6, 4)) - 2013) * 500 + trnNum(s.substr(3, 2)) * 50 +
         trnNum(s.substr(0, 2));
}
inline bool chck(string s) {
  for (int i = 0; i < 10; i++) {
    if (i == 2 || i == 5)
      if (s[i] != '-') return false;
    if (i != 2 && i != 5)
      if (s[i] > '9' || s[i] < '0') return false;
  }
  int y = trnNum(s.substr(6, 4)), m = trnNum(s.substr(3, 2)),
      d = trnNum(s.substr(0, 2));
  if (y > 2015 || y < 2013 || m < 1 || m > 12 || d < 1 || d > dy[m])
    return false;
  return true;
}
int main() {
  cin >> s;
  int ty;
  for (int i = 0; i <= s.length() - 10; i++) {
    if (chck(s.substr(i, 10))) {
      ty = tYtN(s.substr(i, 10));
      dp[ty]++;
      if (dp[ty] > mxd) {
        mxd = dp[ty];
        mxs = s.substr(i, 10);
      }
    }
  }
  cout << mxs << endl;
  return 0;
}
