#include <bits/stdc++.h>
using namespace std;
namespace __gnu_cxx {
template <>
struct hash<std::string> {
  size_t operator()(const std::string& x) const {
    return hash<const char*>()(x.c_str());
  }
};
}  // namespace __gnu_cxx
using __gnu_cxx::hash_map;
template <typename T,
          template <typename ELEM, typename ALLOC = std::allocator<ELEM> >
          class Container>
void Print(const Container<T>& v, const string& delimeter = " ") {
  for (typename Container<T>::const_iterator it = v.begin(); it != v.end();
       ++it) {
    cout << *it << delimeter;
  }
  cout << endl;
}
template <class T>
void Print(const T& v, const string& delimeter = "\n") {
  cout << v << delimeter;
}
bool Digit(char c) { return c >= '0' && c <= '9'; }
int m[] = {-1, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void Valid(int j1, int j2, const string& s, map<string, int>* dates) {
  if (j1 - 2 < 0) return;
  if (j2 + 4 >= ((int)s.size())) return;
  if (!Digit(s[j1 - 2]) || !Digit(s[j1 - 1]) || !Digit(s[j1 + 1]) ||
      !Digit(s[j1 + 2]) || !Digit(s[j2 + 1]) || !Digit(s[j2 + 2]) ||
      !Digit(s[j2 + 3]) || !Digit(s[j2 + 4]))
    return;
  int day = (s[j1 - 2] - '0') * 10 + s[j1 - 1] - '0';
  int month = (s[j1 + 1] - '0') * 10 + s[j1 + 2] - '0';
  int year = (s[j2 + 1] - '0') * 1000 + (s[j2 + 2] - '0') * 100 +
             (s[j2 + 3] - '0') * 10 + (s[j2 + 4] - '0');
  if (year < 2013 || year > 2015) return;
  if (month < 1 || month > 12) return;
  if (day < 1) return;
  if (day > m[month]) return;
  (*dates)[s.substr(j1 - 2, 10)]++;
}
int main() {
  string s;
  cin >> s;
  int n = ((int)s.size());
  int i = 0;
  map<string, int> dates;
  int j1, j2;
  j1 = s.find('-', i);
  if (j1 != string::npos)
    while (j2 < ((int)s.size())) {
      j2 = s.find('-', j1 + 1);
      if (j2 == string::npos) break;
      Valid(j1, j2, s, &dates);
      j1 = j2;
    }
  int mx = -1;
  string ret;
  for (map<string, int>::const_iterator it = dates.begin(); it != dates.end();
       ++it) {
    if (it->second > mx) {
      mx = it->second;
      ret = it->first;
    }
  }
  cout << ret << endl;
  return 0;
}
