#include <bits/stdc++.h>
using namespace std;
string s;
char c[10];
int f, j, d, y, m,
    month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    num[5][25][105];
bool leap(int p) { return p % 4 == 0 && p % 100 != 0 || p % 400 == 0; }
int main() {
  cin >> s;
  for (int i = 0; i + 9 < s.size(); i++) {
    f = 0;
    for (j = i; j < i + 10; j++) {
      if (s[j] == '-') f++;
      if (f > 3) {
        break;
      }
    }
    if (f > 3) continue;
    if (!(s[i + 2] == '-' || s[i + 6] == '-')) continue;
    for (j = i; j < i + 10; j++) c[j - i] = s[j];
    sscanf(c, "%d-%d-%d", &d, &m, &y);
    if (y < 2013 || y > 2015) continue;
    if (m < 1 || m > 12) continue;
    if (d < 1 || d > (leap(y) && m == 2) + month[m]) continue;
    if (num[y - 2013][m][d] == 1) {
      cout << c << '\n';
      return 0;
    }
    num[y - 2013][m][d]++;
  }
  return 0;
}
