#include <bits/stdc++.h>
using namespace std;
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
inline int readInt() {
  int x;
  scanf("%d", &x);
  return x;
}
const double EPS = 1E-8;
const int INF = 2147483647;
const int dxy[5] = {-1, 0, 1, 0, -1};
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(string s) {
  if (s[2] == '-' && s[5] == '-') {
    int m = (s[3] - '0') * 10 + (s[4] - '0');
    if (m >= 1 && m <= 12) {
      int d = (s[0] - '0') * 10 + s[1] - '0';
      if (d >= 1 && d <= days[m]) {
        int y = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 +
                s[9] - '0';
        if (y >= 2013 && y <= 2015) {
          return true;
        }
      }
    }
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  map<string, int> mp;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (i + 10 <= n) {
      string t = s.substr(i, 10);
      if (check(t)) {
        mp[t]++;
      }
    }
  }
  int mx = 0;
  string ans;
  for (auto e : mp) {
    if (mx < e.second) {
      ans = e.first;
      mx = e.second;
    }
  }
  cout << ans << endl;
  return 0;
}
