#include <bits/stdc++.h>
using namespace std;
long long POS(long long x) {
  if (x > 0)
    return x;
  else
    return 0;
}
struct ele {
  long double z, y, x;
  ele() {}
  ele(long double z, long double y, long double x) : z(z), y(y), x(x) {}
  ele operator+(const ele &p) const { return ele(z + p.z, y + p.y, x + p.x); }
  ele operator-(const ele &p) const { return ele(z - p.z, y - p.y, x - p.x); }
  ele operator*(long double con) const {
    return ele(z * con, y * con, x * con);
  }
  ele operator/(long double con) const {
    return ele(z / con, y / con, x / con);
  }
  bool operator<(const ele &rhs) const {
    return make_pair(z, make_pair(y, x)) <
           make_pair(rhs.z, make_pair(rhs.y, rhs.x));
  }
  bool operator==(const ele &rhs) const {
    return make_pair(z, make_pair(y, x)) ==
           make_pair(rhs.z, make_pair(rhs.y, rhs.x));
  }
};
const bool testing = false;
string atob(const int a) {
  stringstream os;
  string b;
  os << a;
  os >> b;
  return b;
}
int btoa(string b) {
  int a;
  if (!(istringstream(b) >> a)) a = 0;
  return a;
}
void program() {
  long long dd = 31, mm = 12, yy = 2015;
  string s;
  cin >> s;
  for (long long i = (0); i < (s.size() - 9); ++i) {
    if ((s[i] >= '0' && s[i] <= '9') &&
        ((s[i + 1] >= '0' && s[i + 1] <= '9') && s[i + 2] == '-')) {
      string res;
      if ((s[i + 3] >= '0' && s[i + 3] <= '9') &&
          (s[i + 4] >= '0' && s[i + 4] <= '9') && s[i + 5] == '-') {
        if (s[i + 6] == '2' && s[i + 7] == '0' && s[i + 8] == '1' &&
            (s[i + 9] == '3' || s[i + 9] == '4' || s[i + 9] == '5')) {
          string day = "";
          day = day + s[i] + s[i + 1];
          long long d = btoa(day);
          string mon = "";
          mon = mon + s[i + 3] + s[i + 4];
          long long m = btoa(mon);
          string year = "";
          year = year + s[i + 6] + s[i + 7] + s[i + 8] + s[i + 9];
          long long y = btoa(year);
          bool flag = false;
          if (m == 1 && d <= 31) flag = true;
          if (m == 2 && d <= 28) flag = true;
          if (m == 3 && d <= 31) flag = true;
          if (m == 4 && d <= 30) flag = true;
          if (m == 5 && d <= 31) flag = true;
          if (m == 6 && d <= 30) flag = true;
          if (m == 7 && d <= 31) flag = true;
          if (m == 8 && d <= 31) flag = true;
          if (m == 9 && d <= 30) flag = true;
          if (m == 10 && d <= 31) flag = true;
          if (m == 11 && d <= 30) flag = true;
          if (m == 12 && d <= 31) flag = true;
          if (flag == true) {
            if (y > yy) {
              continue;
            } else {
              if (m > mm) {
                continue;
              } else {
                if (d > dd) {
                  continue;
                } else {
                  dd = d;
                  mm = m;
                  yy = y;
                }
              }
            }
          }
        }
      }
    }
  }
  cout << dd << "-" << mm << "-" << yy << endl;
}
int main() {
  if (!testing) {
    program();
    return 0;
  }
  FILE *fin = NULL;
  fin = fopen("in.txt", "w+");
  fprintf(fin, "777-444---21-12-2013-12-2013-12-2013---444-777\n");
  fclose(fin);
  freopen("in.txt", "r", stdin);
  printf("test case(1) => expected : \n");
  printf("13-12-2013");
  printf("test case(1) => founded  : \n");
  program();
  return 0;
}
