#include <bits/stdc++.h>
using namespace std;
vector<int> ve;
vector<int> se;
map<int, int> mp;
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int flag[100000];
void solve() {
  int i = 0, j = i + 1, k = i + 2;
  for (; k < ve.size(); i++, j++, k++) {
    if (ve[k] >= 2013 && ve[k] <= 2015) {
      if (ve[j] >= 1 && ve[j] <= 12) {
        if (ve[i] % 100 >= 1 && ve[i] % 100 <= month[ve[j] - 1]) {
          if (!flag[i + 1] && !flag[j + 1]) {
            int d = ve[k] * 10000 + ve[j] * 100 + ve[i] % 100;
            mp[d]++;
          }
        }
      }
    }
  }
  map<int, int>::iterator it = mp.begin();
  int ma = 0;
  while (it != mp.end()) {
    ma = max(it->second, ma);
    it++;
  }
  it = mp.begin();
  while (it != mp.end()) {
    if (it->second == ma) {
      break;
    }
    it++;
  }
  int f = it->first;
  if (f % 100 < 10)
    printf("0%d-", f % 100);
  else
    printf("%d-", f % 100);
  f /= 100;
  if (f % 100 < 10)
    printf("0%d-", f % 100);
  else
    printf("%d-", f % 100);
  f /= 100;
  cout << f << endl;
}
int main() {
  string str, stt;
  int date;
  getline(cin, str);
  int no = 0;
  memset(flag, 0, sizeof(flag));
  for (int i = 0; i < str.length(); i++) {
    if (i + 1 < str.length() && str[i] != '-' && str[i + 1] == '-') no++;
    if (i + 1 < str.length() && str[i] == '-' && str[i + 1] == '-') {
      flag[no] = 1;
    }
    if (str[i] == '-') {
      str[i] = ' ';
    }
  }
  stringstream ss(str);
  stringstream st(str);
  while (ss >> date) {
    st >> stt;
    if (date < 10 && stt.length() < 2) date = -1;
    ve.push_back(date);
  }
  solve();
  ve.clear();
  mp.clear();
  return 0;
}
