#include <bits/stdc++.h>
using namespace std;
int m, k, T, n, tot, M, Maxin, YY, MM, DD;
int date[7][15][35], month[15];
char s[1000005], pm[15][5];
bool pd(char k) {
  if ('0' <= s[k] && s[k] <= '9') return 1;
  return 0;
}
void work(int yy, int k) {
  int mm, dd;
  bool flag;
  if (s[k - 1] != '-' || s[k - 4] != '-') return;
  if (pd(k - 2) && pd(k - 3)) {
    mm = s[k - 2] - '0' + 10 * (s[k - 3] - '0');
    if (1 <= mm && mm <= 12)
      flag = 1;
    else
      return;
  } else
    return;
  if (pd(k - 5) && pd(k - 6)) {
    dd = s[k - 5] - '0' + 10 * (s[k - 6] - '0');
    if (1 <= dd && dd <= month[mm]) {
      date[yy][mm][dd]++;
      if (date[yy][mm][dd] > Maxin) {
        Maxin = date[yy][mm][dd];
        YY = yy;
        MM = mm;
        DD = dd;
      }
    } else
      return;
  } else
    return;
}
void init() {
  scanf("%s", s);
  n = strlen(s);
  month[1] = 31;
  month[2] = 28;
  month[3] = 31;
  month[4] = 30;
  month[5] = 31;
  month[6] = 30;
  month[7] = 31;
  month[8] = 31;
  month[9] = 30;
  month[10] = 31;
  month[11] = 30;
  month[12] = 31;
  for (int i = 6; i < n - 3; ++i) {
    if (s[i] == '2' && s[i + 1] == '0' && s[i + 2] == '1') {
      if (s[i + 3] == '3') work(3, i);
      if (s[i + 3] == '4') work(4, i);
      if (s[i + 3] == '5') work(5, i);
    }
  }
  for (int i = 1; i <= 9; ++i) pm[i][0] = '0', pm[i][1] = '0' + i;
  for (int i = 10; i <= 32; ++i) {
    memset(pm[i], 0, sizeof(pm[i]));
    int x = i / 10, y = i % 10;
    pm[i][0] = '0' + x;
    pm[i][1] = '0' + y;
  }
}
void solve() { printf("%s-%s-201%d", pm[DD], pm[MM], YY); }
int main() {
  init();
  solve();
  return 0;
}
