#include <bits/stdc++.h>
using namespace std;
map<string, long long> mp;
long long days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long checkdate(const string &s) {
  long long month = atoi((s.substr(3, 2)).c_str());
  long long date = atoi((s.substr(0, 2)).c_str());
  long long year = atoi((s.substr(6, 4)).c_str());
  if (month > 0 && month < 13) {
    if (date > 0 && date < days[month] && year <= 2015 && year >= 2013) {
      mp[s]++;
      return 5;
    }
  }
  return 0;
}
signed solve() {
  string s;
  cin >> s;
  long long n = (long long)s.size();
  for (long long i = 0; i < n - 9; i++) {
    i += checkdate(s.substr(i, 10));
  }
  long long max = 0;
  string ans;
  for (auto &x : mp) {
    if (x.second > max) {
      max = x.second;
      ans = x.first;
    }
  }
  cout << ans;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
