#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> MP;
int mt[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  for (int i = 0; i + 10 <= s.length(); i++) {
    string y = s.substr(i, 10);
    if (y[2] != '-' || y[5] != '-') continue;
    int ok = 1;
    for (int j = 0; j < 10; j++) {
      if (j != 2 && j != 5 && !isdigit(y[j])) ok = 0;
    }
    if (!ok) continue;
    int d = (s[0] - '0') * 10 + s[1] - '0';
    int m = (s[3] - '0') * 10 + s[4] - '0';
    string yr = y.substr(y.length() - 4);
    if (yr <= "2012" || yr >= "2016") continue;
    if (d <= 0 || d > mt[m]) continue;
    if (MP.count(y) == 0)
      MP[y] = 1;
    else
      MP[y]++;
  }
  int mx = -1;
  string p;
  for (map<string, int>::iterator it = MP.begin(); it != MP.end(); it++) {
    if (it->second > mx) mx = it->second, p = it->first;
  }
  cout << p << endl;
  return 0;
}
