#include <bits/stdc++.h>
using namespace std;
char s[100010];
map<string, int> mp;
map<string, int>::iterator it;
int z[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool ok(string s) {
  if (s[2] != '-' || s[5] != '-') return false;
  int d = (s[0] - '0') * 10 + s[1] - '0';
  int m = (s[3] - '0') * 10 + s[4] - '0';
  int y =
      (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] - '0';
  if (y > 2015 || y < 2013) return false;
  if (m < 1 || m > 12) return false;
  if (d < 0 || d > z[m]) return false;
  return true;
}
int main() {
  while (~scanf("%s", s)) {
    int l = strlen(s);
    mp.clear();
    for (int i = 0; i < l - 10; i++) {
      string tmp = "";
      for (int j = 0; j < 10; j++) {
        tmp += s[i + j];
      }
      if (ok(tmp)) mp[tmp]++;
    }
    int ans = 0;
    string S = "";
    for (it = mp.begin(); it != mp.end(); it++) {
      if (it->second > ans) {
        ans = it->second;
        S = it->first;
      }
    }
    printf("%s\n", S.c_str());
  }
  return 0;
}
