#include <bits/stdc++.h>
using namespace std;
int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool correct(string s) {
  if (!(s[2] == '-' && s[5] == '-')) return false;
  int d = (s[0] - '0') * 10 + (s[1] - '0');
  int m = (s[3] - '0') * 10 + (s[4] - '0');
  int y = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 +
          (s[9] - '0');
  if (y < 2013 || y > 2015) return false;
  if (m < 1 || m > 12) return false;
  if (d == 0) return false;
  if (d > mdays[m - 1]) return false;
  return true;
}
int main() {
  string s;
  map<string, int> d;
  cin >> s;
  string m;
  int max = 0;
  string apoca;
  for (int i = 0; i < s.size() - 10; i++) {
    m = s.substr(i, 10);
    if (correct(m)) {
      d[m]++;
    }
  }
  for (map<string, int>::iterator i = d.begin(); i != d.end(); i++) {
    if (max < i->second) {
      max = i->second;
      apoca = i->first;
    }
  }
  cout << apoca << endl;
  return 0;
}
