#include <bits/stdc++.h>
const double E = 2.7182818284590452353602874713527;
using namespace std;
map<string, long> mp, mp1;
char dd[10], mm[10], yy[10], ch[1000000], str[100][100005], res[100],
    res1[1000];
int main() {
  mp["01"] = 31, mp["02"] = 28, mp["03"] = 31, mp["04"] = 30, mp["05"] = 31,
  mp["06"] = 30;
  mp["07"] = 31, mp["08"] = 31, mp["09"] = 30, mp["10"] = 31, mp["11"] = 30,
  mp["12"] = 31;
  long len1, len2, len3, i, l, a, k, len, mx;
  while (gets(ch)) {
    l = mx = 0;
    len = strlen(ch);
    for (i = 0; i < len; i++) {
      if (ch[i] >= '0' && ch[i] <= '9') {
        k = 0;
        while (ch[i] != '-' && ch[i] != NULL) {
          str[l][k] = ch[i];
          i++;
          k++;
        }
        str[l][k] = NULL;
        l++;
      }
      if (l > 2) {
        len1 = strlen(str[l - 3]);
        len2 = strlen(str[l - 2]);
        len3 = strlen(str[l - 1]);
        if (len3 >= 4 && len2 >= 2 && len1 >= 2) {
          yy[0] = str[l - 1][0], yy[1] = str[l - 1][1], yy[2] = str[l - 1][2],
          yy[3] = str[l - 1][3];
          yy[4] = NULL;
          if (strcmp(yy, "2013") >= 0 && strcmp(yy, "2015") <= 0) {
            mm[0] = str[l - 2][len2 - 2], mm[1] = str[l - 2][len2 - 1],
            mm[2] = NULL;
            if (strcmp(mm, "01") >= 0 && strcmp(mm, "12") <= 0) {
              dd[0] = str[l - 3][len1 - 2], dd[1] = str[l - 3][len1 - 1],
              dd[2] = NULL;
              sscanf(dd, "%ld", &a);
              if (strcmp(dd, "01") >= 0 && (a <= mp[mm])) {
                res[0] = dd[0], res[1] = dd[1];
                res[2] = '-';
                res[3] = mm[0], res[4] = mm[1];
                res[5] = '-';
                res[6] = yy[0], res[7] = yy[1], res[8] = yy[2], res[9] = yy[3];
                res[10] = NULL;
                mp1[res]++;
                {
                  if (mp1[res] > mx) {
                    strcpy(res1, res);
                    mx = mp1[res];
                  }
                }
              }
            }
          }
        }
        strcpy(str[l - 3], str[l - 2]);
        strcpy(str[l - 2], str[l - 1]);
        l = 2;
      }
    }
    puts(res1);
  }
  return 0;
}
