#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.length() - 10 + 1; ++i) {
    string d = S.substr(i, 10);
    if (isdigit(d[0]) && isdigit(d[1]) && isdigit(d[3]) && isdigit(d[4]) &&
        isdigit(d[6]) && isdigit(d[7]) && isdigit(d[8]) && isdigit(d[8])) {
      int dd = atoi(d.substr(0, 2).c_str());
      int mm = atoi(d.substr(3, 2).c_str());
      int yy = atoi(d.substr(6, 4).c_str());
      if (yy >= 2012 && yy <= 2015 && mm >= 1 && mm <= 12 && dd >= 1 &&
          dd <= months[mm]) {
        M[d]++;
      }
    }
  }
  int best = 0;
  string r = "";
  for (__typeof(M.begin()) it = M.begin(); it != M.end(); ++it) {
    if (best <= it->second) {
      best = it->second;
      r = it->first;
    }
  }
  cout << r << endl;
  return 0;
}
