#include <bits/stdc++.h>
using namespace std;
map<int, int> MAP;
char s[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int ans = 0, c;
  while (cin >> s) {
    int len = strlen(s);
    for (int i = 0; i <= len - 10; i++) {
      int ok = 0;
      for (int j = 0; j < 10; j++) {
        if (j == 2 || j == 5) {
          if (s[i + j] != '-') ok = 1;
        } else {
          if (!(s[i + j] - '0' >= 0 && s[i + j] - '0' < 9)) ok = 1;
        }
      }
      if (ok) continue;
      int year = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
                 (s[i + 8] - '0') * 10 + s[i + 9] - '0';
      if (year > 2015 || year < 2013) continue;
      int m = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
      int d = (s[i] - '0') * 10 + s[i + 1] - '0';
      if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 ||
          m == 12) {
        if (d < 1 || d > 31) continue;
      } else if (m == 4 || m == 6 || m == 9 || m == 11) {
        if (d < 1 || d > 30) continue;
      } else if (m == 2) {
        if (d < 1 || d > 28) continue;
      } else
        continue;
      MAP[d + m * 100 + year * 10000]++;
      if (ans < MAP[d + m * 100 + year * 10000]) {
        ans = MAP[d + m * 100 + year * 10000];
        c = d + m * 100 + year * 10000;
      }
      if (ans = MAP[d + m * 100 + year * 10000] &&
                d + m * 100 + year * 10000 > c) {
        ans = MAP[d + m * 100 + year * 10000];
        c = d + m * 100 + year * 10000;
      }
    }
    printf("%02d-%02d-%04d\n", c % 100, (c % 10000) / 100, c / 10000);
  }
  return 0;
}
