#include <bits/stdc++.h>
using namespace std;
struct Date {
  char date[11];
  int t;
} d[12600];
char s[100005];
int i, j, p, month, day, MAX, flag;
int main() {
  while (scanf("%s", s) != EOF) {
    MAX = 0;
    memset(d, 0, sizeof(d));
    p = 0;
    for (i = 9; s[i] != '\0'; i++) {
      flag = 0;
      month = (s[i - 6] - '0') * 10 + s[i - 5] - '0';
      day = (s[i - 9] - '0') * 10 + s[i - 8] - '0';
      if (month == 2 && day >= 1 && day <= 28)
        flag = 1;
      else if ((month == 1 || month == 3 || month == 5 || month == 7 ||
                month == 8 || month == 10 || month == 12) &&
               day >= 1 && day <= 31)
        flag = 1;
      else if (day >= 1 && day <= 30)
        flag = 1;
      if ((s[i] == '3' || s[i] == '4' || s[i] == '5') && s[i - 1] == '1' &&
          s[i - 2] == '0' && s[i - 3] == '2' && s[i - 4] == '-' &&
          s[i - 7] == '-' && flag) {
        for (j = 0; j <= 9; j++) d[p].date[j] = s[i - 9 + j];
        d[p].date[10] = '\0';
        p++;
      }
    }
    for (i = 1; i < p; i++)
      for (j = i + 1; j < p; j++)
        if (strcmp(d[i].date, d[j].date) == 0) d[i].t++;
    for (i = 1; i < p; i++) {
      if (d[MAX].t < d[i].t) MAX = i;
    }
    printf("%s\n", d[MAX].date);
  }
  return 0;
}
