#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int maxn = 100;
const int alphabet = 26;
const int dx[] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dy[] = {2, -2, 2, -2, 1, -1, 1, -1};
const int dz[] = {1, 1, 0, 0, -1, 1};
map<string, int> mk;
vector<string> v;
int a[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    b[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 9; i++) {
    string t = s.substr(i, 10);
    if (mk[t] == 0) v.push_back(t);
    mk[t]++;
  }
  string ans = "";
  for (int i = 0; i < v.size(); i++) {
    if (v[i][0] >= '0' && v[i][1] >= '0' && v[i][2] == '-' && v[i][3] >= '0' &&
        v[i][4] >= '0' && v[i][5] == '-' && v[i][6] >= '0' && v[i][7] >= '0' &&
        v[i][8] >= '0' && v[i][9] >= '0') {
      int d = (v[i][0] - '0') * 10 + (v[i][1] - '0');
      int m = (v[i][3] - '0') * 10 + (v[i][4] - '0');
      int second = (v[i][6] - '0') * 1000 + (v[i][7] - '0') * 100 +
                   (v[i][8] - '0') * 10 + (v[i][9] - '0');
      if (d > 31 || m > 12 || d == 0 || m == 0 || second <= 2012 ||
          second > 2015)
        continue;
      if ((second % 4 == 0 && second % 100 == 0) || (second % 400 == 0)) {
        if (b[m - 1] >= d) {
          if (mk[v[i]] > mk[ans] && ans != "")
            ans = v[i];
          else if (ans == "")
            ans = v[i];
        }
      } else {
        if (b[m - 1] >= d) {
          if (mk[v[i]] > mk[ans] && ans != "")
            ans = v[i];
          else if (ans == "")
            ans = v[i];
        }
      }
    }
  }
  cout << ans;
}
