#include <bits/stdc++.h>
using namespace std;
int mes[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> M;
bool isValid(string s) {
  if (s[2] != '-' || s[5] != '-') return false;
  s[2] = s[5] = ' ';
  istringstream in(s);
  int d, m, a;
  in >> d >> m >> a;
  if (m <= 0 || m > 12) return false;
  if (a < 2013 || a > 2015) return false;
  if (d <= 0 || d > mes[m]) return false;
  M[s]++;
}
int main() {
  string s;
  while (cin >> s) {
    for (int i = 0; i < s.size(); i++) {
      if (i >= 9) isValid(s.substr(i - 9, 10));
    }
    int maxi = 0;
    string ans;
    map<string, int>::iterator it;
    for (it = M.begin(); it != M.end(); it++)
      if (maxi < (*it).second) maxi = (*it).second, ans = (*it).first;
    ans[2] = ans[5] = '-';
    cout << ans << endl;
  }
}
