#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int days[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mx = -1;
string ans, neww;
int main() {
  string a, b = "dd-mm-yyyy";
  cin >> a;
  int d, m, y, j;
  for (int i = 0; i < a.length() - b.length() + 1; i++) {
    neww = a.substr(i, b.length());
    if (sscanf((neww + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
      continue;
    if (d >= 1 && d <= days[m] && m <= 12 && m >= 1 && y >= 2013 && y <= 2015) {
      if (mx < ++mp[neww]) {
        mx = mp[neww];
        ans = neww;
      }
    }
  }
  cout << ans;
  return 0;
}
