#include <bits/stdc++.h>
using namespace std;
bool valid(string s) {
  const int types[] = {0, 0, 1, 0, 0, 1, 0, 0, 0, 0};
  for (int i = 0; i < 10; i++) {
    if (types[i] == 0 && !isdigit(s[i])) {
      return false;
    }
    if (types[i] == 1 && s[i] != '-') {
      return false;
    }
  }
  const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int day = (s[0] - '0') * 10 + s[1] - '0';
  int month = (s[3] = '0') * 10 + s[4] - '0';
  int year = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 +
             (s[9] - '0');
  if (year < 2013 || year > 2015) {
    return false;
  }
  if (month < 1 || month > 12) {
    return false;
  }
  if (day < 1 || day > days[month]) {
    return false;
  }
}
int main() {
  string s;
  cin >> s;
  map<string, int> app;
  for (int i = 0; i + 10 <= s.size(); i++) {
    string sub = "";
    for (int j = 0; j < 10; j++) {
      sub += s[i + j];
    }
    if (valid(sub)) {
      app[sub]++;
    }
  }
  string res;
  int cnt = 0;
  for (map<string, int>::iterator it = app.begin(); it != app.end(); ++it) {
    if (cnt < it->second) {
      cnt = it->second;
      res = it->second;
    }
  }
  cout << res << endl;
  return 0;
}
