#include <bits/stdc++.h>
using namespace std;
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << '\n';
}
long long days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool is_numeric(char c) { return c >= '0' and c <= '9'; }
bool check(string s) {
  string temp;
  if (!is_numeric(s[0])) return false;
  temp += s[0];
  if (!is_numeric(s[1])) return false;
  temp += s[1];
  long long day = stoll(temp);
  temp = "";
  if (s[2] != '-') return false;
  if (!is_numeric(s[3])) return false;
  temp += s[3];
  if (!is_numeric(s[4])) return false;
  temp += s[4];
  long long month = stoll(temp);
  if (month < 1 or month > 12) return false;
  if (day < 1 or day > days[month - 1]) return false;
  if (s[5] != '-') return false;
  temp = "";
  for (long long i = 6; i < 10; i++) {
    if (!is_numeric(s[i])) return false;
    temp += s[i];
  }
  long long year = stoll(temp);
  if (year >= 2013 and year <= 2015)
    return true;
  else
    return false;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  map<string, long long> freq;
  long long n = s.length();
  for (long long i = 0; i < n - 10; i++) {
    string t;
    for (long long j = i; j < i + 10; j++) t += s[j];
    if (check(t)) freq[t]++;
  }
  long long res = 0;
  string ans;
  for (auto &x : freq) {
    if (x.second > res) {
      res = x.second;
      ans = x.first;
    }
  }
  cout << ans << '\n';
  time();
  return 0;
}
