#include <bits/stdc++.h>
using namespace std;
int a[100005], j = 0, pos = 0, mmax = 0;
string s, t[100005];
bool CheckDate(string k);
int main() {
  getline(cin, s);
  for (int i = 0; i <= s.size() - 10; i++)
    if (CheckDate(s.substr(i, 10))) t[j++] = s.substr(i, 10);
  for (int i = 0; i < j; i++) {
    for (int k = i - 1; k >= 0; k--)
      if (t[i] == t[k]) {
        a[i] = a[k] + 1;
        break;
      }
    if (a[i] > mmax) {
      mmax = a[i], pos = i;
    }
  }
  cout << t[pos];
  return 0;
}
bool CheckDate(string k) {
  if (k[2] != '-' || k[5] != '-') return false;
  for (int i = 0; i < 10; i++)
    if ((i != 2 && i != 5) && k[i] == '-') return false;
  int d = (k[0] - '0') * 10 + (k[1] - '0'),
      m = (k[3] - '0') * 10 + (k[4] - '0'),
      y = (k[6] - '0') * 1000 + (k[7] - '0') * 100 + (k[8] - '0') * 10 +
          (k[9] - '0');
  if (m > 12 || m < 1 || y > 2015 || y < 2013 || d < 1 || d > 31) return false;
  switch (m) {
    case 4:
    case 6:
    case 9:
    case 11:
      if (d == 31) return false;
    case 2:
      if (d > 29) return false;
  }
  return true;
}
