#include <bits/stdc++.h>
using namespace std;
inline bool parse_substr(char *str, int &y, int &m, int &d) {
  int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  bool ok = ('0' <= (str[0]) && (str[0]) <= '9') &&
            ('0' <= (str[1]) && (str[1]) <= '9') && str[2] == '-' &&
            ('0' <= (str[3]) && (str[3]) <= '9') &&
            ('0' <= (str[4]) && (str[4]) <= '9') && str[5] == '-' &&
            ('0' <= (str[6]) && (str[6]) <= '9') &&
            ('0' <= (str[7]) && (str[7]) <= '9') &&
            ('0' <= (str[8]) && (str[8]) <= '9') &&
            ('0' <= (str[9]) && (str[9]) <= '9');
  if (!ok) {
    return 0;
  }
  sscanf(str, "%d-%d-%d", &d, &m, &y);
  ok = (2013 <= y && y <= 2015) && (1 <= m && m <= 12) &&
       (1 <= d && d <= days[m]);
  return ok;
}
void solve_the_problem(void) {
  map<int, int> cnt;
  char *str = (char *)malloc(100010);
  fgets(str, 100010, stdin);
  int len = strlen(str);
  for (int i = 0; i < len - 9; ++i) {
    int y, m, d;
    if (parse_substr(str + i, y, m, d)) {
      int p = y * 100 * 100 + m * 100 + d;
      if (!cnt.count(p)) {
        cnt[p] = 1;
      } else {
        ++cnt[p];
      }
    }
  }
  map<int, int>::iterator maxp = cnt.begin();
  for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
    if (maxp->second < it->second) {
      maxp = it;
    }
  }
  int p = maxp->first;
  fprintf(stdout, "%02d-%02d-%02d\n", p % 100, p / 100 % 100, p / 100 / 100);
}
int main(int argc, char *argv[]) {
  int cl = 0;
  if (argc > 1) {
    cl = clock();
    freopen("input.txt", "rt", stdin);
  }
  solve_the_problem();
  if (argc > 1) {
    fprintf(stderr, "CPU time: %.5lf\n", double(clock() - cl) / CLOCKS_PER_SEC);
  }
  return 0;
}
