#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
bool check(vector<string> &tmp, string &s) {
  if (tmp[0].size() < 2 || tmp[1].size() < 2 || tmp[2].size() < 4) return 0;
  if (tmp[1] == "02") {
    if (tmp[0] >= "01" && tmp[0] <= "28")
      if (tmp[2] >= "2013" && tmp[2] <= "2015") {
        s = tmp[0] + "-" + tmp[1] + "-" + tmp[2];
        return 1;
      }
  } else if (tmp[1] >= "01" && tmp[1] <= "07") {
    int x = tmp[1][1] - '0';
    string comp = "";
    if (x % 2 == 0)
      comp = "30";
    else
      comp = "31";
    if (tmp[0] >= "01" && tmp[0] <= comp)
      if (tmp[2] >= "2013" && tmp[2] <= "2015") {
        s = tmp[0] + "-" + tmp[1] + "-" + tmp[2];
        return 1;
      }
  } else if (tmp[1] >= "08" && tmp[1] <= "12") {
    int x = tmp[1][1] - '0';
    string comp = "";
    if (x % 2)
      comp = "30";
    else
      comp = "31";
    if (tmp[0] >= "01" && tmp[0] <= comp)
      if (tmp[2] >= "2013" && tmp[2] <= "2015") {
        s = tmp[0] + "-" + tmp[1] + "-" + tmp[2];
        return 1;
      }
  }
  return 0;
}
void cons(deque<string> &d) {
  if (d.size() < 3) return;
  vector<string> tmp(3);
  int sub = 2;
  for (int i = 0; i < 3; i++) {
    tmp[i] = "";
    string s = d[i];
    if (i == 2) sub = 4;
    for (int j = (int)s.size() - 1; j >= (int)s.size() - sub; j--)
      tmp[i] = s[j] + tmp[i];
  }
  string ans = "";
  if (check(tmp, ans)) m[ans]++;
  return;
}
int main() {
  string s;
  cin >> s;
  s += '-';
  deque<string> d;
  string tmp = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '-') {
      tmp += s[i];
      if (d.size() == 2 && tmp.size() >= 4) {
        d.push_back(tmp);
        tmp = "";
      } else if (d.size() == 3) {
        d[2] += tmp;
        tmp = "";
      }
    }
    if (d.size() == 3 || s[i] == '-') {
      if (d.size() <= 2) {
        if (tmp == "")
          d.push_back("0");
        else
          d.push_back(tmp);
      }
      tmp = "";
      if (d.size() == 3) {
        cons(d);
      }
      if (d.size() == 3 && s[i] == '-') d.pop_front();
    }
  }
  if (d.size() == 3) cons(d);
  map<string, int>::iterator itr = m.begin();
  int maxi = -1;
  string ans = "";
  for (; itr != m.end(); itr++) {
    if (itr->second > maxi) {
      maxi = itr->second;
      ans = itr->first;
    }
  }
  cout << ans << endl;
  return 0;
}
