#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> cnt;
string ans;
int q;
int to_int(string s) {
  int res = 0;
  for (int i = 0; i < s.size(); i++) {
    res = res * 10 + (s[i] - '0');
  }
  return res;
}
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool correct(string &s) {
  int d, m, y;
  if (s[2] != '-') return false;
  if (s[5] != '-') return false;
  int c = 0;
  for (int i = 0; i < 10; i++) {
    if (s[i] == '-') c++;
  }
  if (c > 2) return false;
  d = to_int(s.substr(0, 2));
  m = to_int(s.substr(3, 2));
  y = to_int(s.substr(6, 4));
  if (y > 2015) return false;
  if (y < 2013) return false;
  if (m < 1) return false;
  if (m > 12) return false;
  if (d < 1) return false;
  if (d > days[m]) return false;
  return true;
}
int main() {
  cin >> s;
  for (int i = 0; i < s.size() - 10; i++) {
    string t = s.substr(i, 10);
    if (correct(t)) {
      cnt[t]++;
    }
  }
  for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); it++) {
    if (it->second > q) {
      q = it->second;
      ans = it->first;
    }
  }
  cout << ans;
  return 0;
}
