#include <bits/stdc++.h>
using namespace std;
int readint() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && c != '-')
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
inline string tos(int x) {
  string s;
  while (x) s = (char)(x % 10 + '0') + s, x /= 10;
  return s;
}
inline int pt(int a[], int l, int r) {
  int p, i, j;
  p = a[l];
  i = l;
  j = r + 1;
  for (;;) {
    while (a[++i] < p)
      if (i >= r) break;
    while (a[--j] > p)
      if (j <= l) break;
    if (i >= j)
      break;
    else
      swap(a[i], a[j]);
  }
  if (j == l) return j;
  swap(a[l], a[j]);
  return j;
}
inline void q_sort(int a[], int l, int r) {
  int q;
  if (r > l) {
    q = pt(a, l, r);
    q_sort(a, l, q - 1);
    q_sort(a, q + 1, r);
  }
}
map<string, int> msi;
int daynum[15] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int toi(string s) {
  int rt = 0;
  for (int i = 0; i < s.size(); i++) rt = rt * 10 + s[i] - '0';
  return rt;
}
inline bool isleap(int x) {
  return (x % 4 == 0 && x % 100 != 0) || (x % 400 == 0);
}
inline bool ok(string s) {
  string dd, mm, yyyy;
  int d, m, y;
  if (s[2] != '-' || s[5] != '-') return 0;
  int sum = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == '-') sum++;
  if (sum != 2) return 0;
  dd = s.substr(0, 2);
  mm = s.substr(3, 2);
  yyyy = s.substr(6);
  d = toi(dd);
  m = toi(mm);
  if (m > 12) return 0;
  y = toi(yyyy);
  if (m == 29) {
    int ddd = 28;
    ddd += isleap(y);
    return d <= ddd;
  } else {
    int ddd = daynum[m];
    return d < ddd;
  }
}
int main() {
  string s, t;
  cin >> s;
  if (s.size() < 10) {
    cout << 0 << endl;
    return 0;
  }
  t = s.substr(0, 10);
  if (ok(t)) msi[t]++;
  for (int i = 1; i <= s.size() - 10; i++) {
    t = s.substr(i, 10);
    if (ok(t)) msi[t]++;
  }
  int mx = 0;
  string ans = "";
  for (map<string, int>::iterator it = msi.begin(); it != msi.end(); it++) {
    if (mx < it->second)
      mx = it->second, ans = it->first;
    else if (mx == it->second)
      ans = max(ans, it->first);
  }
  cout << ans << endl;
  return 0;
}
