#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int mm[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, maxn = -1;
string s, ans;
int main() {
  cin >> s;
  if (s.size() - 9 < 1) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < s.size() - 9; i++) {
    string kk = s.substr(i, 10);
    int year = (kk[9] - 48) + (kk[8] - 48) * 10 + (kk[7] - 48) * 100 +
               (kk[6] - 48) * 1000,
        month = (kk[4] - 48) + (kk[3] - 48) * 10,
        day = (kk[1] - 48) + (kk[0] - 48) * 10;
    if (year > 2015 || year < 2013 || month < 1 || month > 12 || kk[2] != '-' ||
        kk[5] != '-')
      continue;
    if (day < 1 || day > mm[month]) continue;
    mp[kk]++;
    if (mp[kk] > maxn) {
      ans = kk;
      maxn = mp[kk];
    }
  }
  cout << ans << endl;
  return 0;
}
