#include <bits/stdc++.h>
using namespace std;
int is[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
int main(int argc, char const *argv[]) {
  char s[100010];
  scanf("%s", s);
  int l = strlen(s);
  string st;
  for (int i = 0; i + 10 < l; i++) {
    if (s[i] == '-') continue;
    int j = i;
    for (; j < i + 10; j++) {
      if (s[j] != '-' && (j == i + 2 || j == i + 5)) break;
      if ((s[j] < '0' || s[j] > '9') && !(j == i + 2 || j == i + 5)) break;
    }
    if (j == i + 10) {
      int day = (s[i] - '0') * 10 + s[i + 1] - '0';
      int month = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
      int year = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
                 (s[i + 8] - '0') * 10 + s[i + 9] - '0';
      if (year < 2013 || year > 2015) continue;
      if (month < 1 || month > 12) continue;
      if (day > is[month] || day <= 0) continue;
      j = i;
      st.clear();
      for (int k = 0; k < 10; j++, k++) st += s[j];
      mp[st]++;
    }
  }
  string ans;
  int maxx = 0;
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
    if (it->second > maxx) {
      ans = it->first;
      maxx = it->second;
    }
  cout << ans << endl;
  return 0;
}
