#include <bits/stdc++.h>
using namespace std;
char s[100006], wc[13];
bool ok[10];
long D[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, long> MAP;
long anss;
string ans, now;
int main() {
  std::ios::sync_with_stdio(false);
  long i, j, d, m, y;
  cin >> s;
  ok[2] = ok[5] = 1;
  for (i = 0; s[i + 9] != '\0'; ++i) {
    for (j = 0; j < 10; ++j)
      if ((s[j + i] == '-') != ok[j]) break;
    if (j == 10) {
      for (j = 0; j < 10; ++j) wc[j] = s[j + i];
      wc[10] = '\0';
      now = wc;
      d = (now[0] - '0') * 10 + (now[1] - '0');
      m = (now[3] - '0') * 10 + (now[4] - '0');
      y = (now[6] - '0') * 1000 + (now[7] - '0') * 100 + (now[8] - '0') * 10 +
          (now[9] - '0');
      if (m > 12 || m == 0 || y < 2013 || y > 2015) continue;
      if (d > D[m] || d == 0) continue;
      if (++MAP[now] > anss) {
        anss = MAP[now];
        ans = now;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
