#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin.tie(0), cout.tie(0);
  ;
  long long int t, n, i, j, a, m, k;
  string s, b = "", c = "";
  long long int arr[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  map<string, long long int> mp;
  cin >> s;
  for (i = 0; i < s.size() - 3; i++) {
    if (s[i] == '-' && s[i + 1] >= '0' && s[i + 1] <= '9' && s[i + 2] >= '0' &&
        s[i + 2] <= '9' && s[i + 3] == '-') {
      c += s[i + 1];
      c += s[i + 2];
      m = stoi(c);
      cout << m << endl;
      c = "";
      if (m > 12) continue;
      if (i - 2 >= 0) {
        if (s[i - 1] >= '0' && s[i - 1] <= '9' && s[i - 2] >= '0' &&
            s[i - 2] <= '9') {
          c += s[i - 2];
          c += s[i - 1];
          n = stoi(c);
          c = "";
          if (arr[m] < n) continue;
          if (i + 7 <= s.size()) {
            if (s[i + 4] == '2' && s[i + 5] == '0' && s[i + 6] == '1' &&
                s[i + 7] >= '3' && s[i + 7] <= '5') {
              for (j = i - 2; j <= i + 7; j++) {
                b += s[j];
              }
              mp[b]++;
              b = "";
            }
          }
        }
      }
    }
  }
  long long int mn = 0;
  for (auto it : mp) {
    if (it.second > mn) {
      b = it.first;
      mn = it.second;
    }
  }
  cout << b << endl;
  return 0;
}
