#include <bits/stdc++.h>
using namespace std;
int c[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool correct(string s) {
  if (s[0] < '0' || s[0] > '9' || s[1] < '0' || s[1] > '9') return false;
  int day = 10 * (int)(s[0] - '0') + (int)(s[1] - '0');
  if (s[2] != '-') return false;
  if (s[3] < '0' || s[3] > '1' || s[4] < '0' || s[4] > '9') return false;
  int month = 10 * (int)(s[3] - '0') + (int)(s[4] - '0');
  if (s[5] != '-') return false;
  if (s[6] != '2' || s[7] != '0' || s[8] != '1' || s[9] > '5' || s[9] < '3')
    return false;
  int year = 1000 * (int)(s[6] - '0') + 100 * (int)(s[7] - '0') +
             10 * (int)(s[8] - '0') + (int)(s[9] - '0');
  if (day > c[month]) return false;
  return true;
}
int main() {
  string s;
  cin >> s;
  map<string, int> m;
  map<int, string> m1;
  vector<int> res;
  for (int i = 0; i < (int)((int)s.size() - 10); i++) {
    string s1 = s.substr(i, 10);
    if (correct(s1)) {
      if (m.count(s1)) {
        res[m[s1]] += 1;
      } else {
        res.push_back(1);
        m[s1] = (int)res.size() - 1;
        m1[(int)m.size() - 1] = s1;
      }
    }
  }
  int MAX = -1000000000;
  string ans;
  for (int i = 0; i < (int)((int)res.size()); i++)
    if (res[i] > MAX) {
      MAX = res[i];
      ans = m1[i];
    }
  cout << ans;
}
