#include <bits/stdc++.h>
using namespace std;
int d[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  map<string, int> mp;
  string a, m;
  long long int i, n, flag, cnt = 0, co = 0;
  cin >> a;
  vector<int> b;
  for (i = 0; i < a.length(); i++) {
    if (a[i] != '-') {
      cnt = cnt * 10 + (a[i] - '0');
      co++;
    } else {
      if (co == 1) cnt = 0;
      b.push_back(cnt);
      co = 0;
      cnt = 0;
    }
  }
  if (a[i - 1] != '-') b.push_back(cnt);
  for (i = 0; i < b.size() - 2; i++) {
    m = "";
    flag = 0;
    if (b[i + 1] >= 1 && b[i + 1] <= 12) {
      co = b[i + 2];
      while (co > 0) {
        if (co >= 2013 && co <= 2015) {
          flag = 1;
          break;
        }
        co /= 10;
      }
      if ((b[i] % 100 > 0 && (b[i] % 100 <= d[b[i + 1] - 1]) && (flag == 1))) {
        m += ((b[i] % 100) / 10 + '0');
        m += ((b[i] % 100) % 10 + '0');
        m += "-";
        m += ((b[i + 1] % 100) / 10 + '0');
        m += ((b[i + 1] % 100) % 10 + '0');
        m += "-";
        m += ((co / 1000) + '0');
        co = (co % 1000);
        m += ((co / 100) + '0');
        co = (co % 100);
        m += ((co / 10) + '0');
        m += ((co % 10) + '0');
        mp[m]++;
      }
    }
  }
  map<string, int>::iterator itr;
  cnt = 0;
  for (itr = mp.begin(); itr != mp.end(); itr++) {
    if (cnt < itr->second) {
      cnt = itr->second;
      m = itr->first;
    }
  }
  cout << m << "\n";
  return 0;
}
