#include <bits/stdc++.h>
using namespace std;
char S[200100];
map<pair<pair<int, int>, int>, int> M;
inline bool ok(int mj, int d) {
  if (d < 1) return 0;
  if (mj == 1 && d > 31) return 0;
  if (mj == 2 && d > 28) return 0;
  if (mj == 3 && d > 31) return 0;
  if (mj == 4 && d > 30) return 0;
  if (mj == 5 && d > 31) return 0;
  if (mj == 6 && d > 30) return 0;
  if (mj == 7 && d > 31) return 0;
  if (mj == 8 && d > 31) return 0;
  if (mj == 9 && d > 30) return 0;
  if (mj == 10 && d > 31) return 0;
  if (mj == 11 && d > 30) return 0;
  if (mj == 12 && d > 31) return 0;
  return 1;
}
int main(void) {
  int y, m, d;
  scanf("%s", S);
  int n = strlen(S);
  int maks = 0;
  for (int i = 0; i < n; i++) {
    int date = 0;
    if (S[i] != '-' && S[i + 1] != '-') {
      date = date * 10 + (S[i] - '0');
      date = date * 10 + (S[i + 1] - '0');
    } else
      continue;
    if (S[i + 2] != '-') continue;
    int mont = 0;
    if (S[i + 3] != '-' && S[i + 4] != '-') {
      mont = mont * 10 + (S[i + 3] - '0');
      mont = mont * 10 + (S[i + 4] - '0');
    } else
      continue;
    if (S[i + 5] != '-') continue;
    int year = 0;
    if (S[i + 6] != '-' && S[i + 7] != '-' && S[i + 8] != '-' &&
        S[i + 9] != '-') {
      year = year * 10 + (S[i + 6] - '0');
      year = year * 10 + (S[i + 7] - '0');
      year = year * 10 + (S[i + 8] - '0');
      year = year * 10 + (S[i + 9] - '0');
    } else
      continue;
    if (year < 2013 || year > 2015) continue;
    if (mont < 1 || mont > 12) continue;
    if (!ok(mont, date)) continue;
    M[make_pair(make_pair(date, mont), year)]++;
  }
  map<pair<pair<int, int>, int>, int>::iterator it = M.begin();
  pair<pair<int, int>, int> A = (it->first);
  printf("%02d-%02d-%d\n", A.first.first, A.first.second, A.second);
  return 0;
}
