#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T &t, T f) {
  if (t < f) t = f;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T cube(T x) {
  return x * x * x;
}
string out(long long x) {
  stringstream ss;
  ss << x;
  string res;
  ss >> res;
  return res;
}
long long out(string s) {
  stringstream ss;
  ss << s;
  long long res;
  ss >> res;
  return res;
}
template <typename T>
void print(const vector<vector<T> > &v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << "i = " << i << endl;
    for (int j = 0; j < (int)(v[i].size()); j++) {
      cout << v[i][j] << ' ';
    }
    cout << endl;
    cout << endl;
  }
}
template <typename T>
void print(const vector<T> &v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << v[i] << ' ';
  }
  cout << endl;
}
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int MAXN = 100000 + 7;
string buf;
int nums[] = {0, 1, 3, 4, 6, 7, 8, 9};
int pair2num(int i) {
  int a = buf[i] - '0';
  int b = buf[i + 1] - '0';
  return a * 10 + b;
}
map<int, int> cnt;
void isvalid(int i) {
  bool fl = false;
  for (int j = 0; j < (int)(8); j++) {
    fl |= buf[i + nums[j]] == '-';
  }
  fl |= buf[i + 2] != '-';
  fl |= buf[i + 5] != '-';
  if (fl) return;
  int m = pair2num(i + 3);
  int d = pair2num(i);
  if (m < 1 || m > 12 || !d || month[m - 1] < d) {
    return;
  }
  int year = pair2num(i + 6) * 100 + pair2num(i + 8);
  if (year < 2013 || year > 2015) return;
  int sum = 0;
  sum += (year - 2013) * 365;
  for (int j = 0; j < (int)(m - 1); j++) {
    sum += month[j];
  }
  sum += d - 1;
  cnt[sum]++;
  return;
}
int main() {
  cin >> buf;
  int n = buf.size();
  for (int i = 0; i < (int)(n - 10 + 1); i++) {
    isvalid(i);
  }
  map<int, int>::iterator it;
  int mem;
  int ma = -1;
  for (it = (cnt).begin(); it != (cnt).end(); it++) {
    if (it->second > ma) {
      ma = it->second;
      mem = it->first;
    }
  }
  int year = 2013 + mem / 365;
  mem %= 365;
  int mon;
  int day;
  for (int i = 0; i < 12; i++) {
    if (mem < month[i]) {
      day = mem + 1;
      mon = i + 1;
      break;
    }
    mem -= month[i];
  }
  cout << day << '-' << mon << '-' << year << endl;
  return 0;
}
