#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline string toString(T a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <typename T>
inline int toLong(T a) {
  int res;
  istringstream os(a);
  os >> res;
  return res;
}
template <typename T>
inline T SQ(T a) {
  return a * a;
}
template <typename T>
inline T GCD(T a, T b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
template <typename T>
inline unsigned long long BIGMOD(T a, T b, T m) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return SQ(BIGMOD(a, b / 2, m)) % m;
  else
    return (a % m * BIGMOD(a, b - 1, m)) % m;
}
template <typename T>
inline vector<string> PARSE(T str) {
  vector<string> res;
  string s;
  istringstream os(str);
  while (os >> s) res.push_back(s);
  return res;
}
template <typename T>
inline unsigned long long DIST(T A, T B) {
  unsigned long long res =
      (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
  return res;
}
template <typename T>
inline double cosAngle(T a, T b, T c) {
  double res = a * a + b * b - c * c;
  res = res / (2 * a * b);
  res = acos(res);
  return res;
}
template <typename T>
inline T POWER(T base, int po) {
  T res = 1;
  if (base == 0) return 0;
  for (int i = (0); i < (po); i++) res *= base;
  return res;
}
template <typename T>
inline bool IS_ON(T mask, T pos) {
  return mask & (1 << pos);
}
template <typename T>
inline int OFF(T mask, T pos) {
  return mask ^ (1 << pos);
}
template <typename T>
inline int ON(T mask, T pos) {
  return mask | (1 << pos);
}
template <typename T>
inline bool INSIDE_GRID(int R, int C, int ro, int clm) {
  if (R >= 0 && C >= 0 && R < ro && C < clm) return 1;
  return 0;
}
int a, b, n;
int cnt = 0;
string s, res, ans;
int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
bool isvalid(int pos) {
  res = "";
  string hh = "";
  if (isdigit(s[pos]) && isdigit(s[pos + 1]) && s[pos + 2] == '-' &&
      isdigit(s[pos + 3]) && isdigit(s[pos + 4]) && s[pos + 5] == '-' &&
      isdigit(s[pos + 6]) && isdigit(s[pos + 7]) && isdigit(s[pos + 8]) &&
      isdigit(s[pos + 9])) {
    for (int i = 0; i < 10; i++) res += s[pos + i];
    hh += s[pos + 3];
    hh += s[pos + 4];
    int m = toLong(hh);
    hh = "";
    hh += s[pos];
    hh += s[pos + 1];
    int n = toLong(hh);
    if (n && m < 13 && m > 0 && month[m] >= n) {
      mp[res]++;
      if (mp[res] > cnt) cnt = mp[res], ans = res;
    }
  }
}
int main() {
  cin >> s;
  int l = s.length();
  for (int i = (0); i < (12); i++) s += '*';
  ans = "";
  cnt = 0;
  for (int i = (0); i < (l); i++) {
    isvalid(i);
  }
  cout << ans << endl;
  return 0;
}
