#include <bits/stdc++.h>
using namespace std;
bool place(char c, int pos) {
  switch (pos) {
    case 2:
    case 5:
      return c == '-';
    default:
      return c != '-';
  }
}
bool correct(const string &s) {
  for (int i = 0; i < 10; i++) {
    if (place(s[i], i) == false) return false;
  }
  int day = atoi(s.substr(0, 2).c_str());
  int month = atoi(s.substr(3, 2).c_str());
  int year = atoi(s.substr(6, 4).c_str());
  if (year < 2013 || year > 2015) return false;
  if (month > 12) return false;
  int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (day > days[month]) return false;
  return true;
}
int main() {
  string s;
  cin >> s;
  map<string, int> dates;
  for (int i = 0; i + 10 <= s.length(); i++) {
    string t = s.substr(i, 10);
    if (correct(t)) dates[t]++;
  }
  int _max = 0;
  string result;
  for (map<string, int>::iterator it = dates.begin(); it != dates.end(); it++) {
    if (it->second > _max) {
      _max = it->second;
      result = it->first;
    }
  }
  cout << result;
  return 0;
}
