#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
bool validate(string s) {
  int month = (s[3] - '0') * 10 + (s[4] - '0'),
      day = (s[0] - '0') * 10 + (s[1] - '0');
  if (month <= 12 && month >= 1) {
    if ((day == 28 && month == 2) || (day <= 31 && month % 2 == 0) ||
        (day <= 30 && month % 2 != 0)) {
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
void solve() {
  string s, sub, ans;
  unordered_map<string, int> record;
  bool valid;
  cin >> s;
  smatch match;
  int maxi = 0, start, end;
  regex r("[0-9][0-9]-[0-9][0-9]-201[3-5]");
  string test = "";
  for (int i = 0; i < s.length(); i++) {
    test.push_back(s[i]);
    int temp = test.length();
    start = max(0, temp - 10);
    end = test.length();
    test = test.substr(start, end);
    if (regex_match(test, r)) {
      valid = validate(test);
      if (valid) {
        record[test] += 1;
        if (record[test] > maxi) {
          maxi = record[test];
          ans = test;
        }
      }
    }
  }
  cout << ans << "\n";
}
