#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char ss[2000][10];
  int a[2000] = {0};
  for (int i = 0; i < 1095; i++) a[i] = 0;
  int d, m, y, index;
  for (int i = 0; i < s.length() - 9; i++) {
    bool p = 0;
    d = (s[i] - '0') * 10 + (s[i + 1] - '0');
    m = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
    y = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
        (s[i + 8] - '0') * 10 + (s[i + 9] - '0');
    if (s[i + 2] == '-' && s[i + 5] == '-') {
      if (d >= 1 && d <= 31 && m <= 12 && m >= 1 && y >= 2013 && y <= 2015) {
        if (d == 31) {
          if ((m % 2 == 1 && m <= 7) || (m % 2 == 0 && m >= 8)) {
            p = 1;
          }
        } else if (m == 2)
          if (d <= 28)
            p = 1;
          else
            p = 1;
      }
    }
    if (p) {
      index = d - 1;
      if (y == 2014) index += 365;
      if (y == 2015) index += (365 * 2);
      switch (m) {
        case 2:
          index += 31;
          break;
        case 3:
          index += 59;
          break;
        case 4:
          index += 90;
          break;
        case 5:
          index += 120;
          break;
        case 6:
          index += 151;
          break;
        case 7:
          index += 181;
          break;
        case 8:
          index += 212;
          break;
        case 9:
          index += 243;
          break;
        case 10:
          index += 273;
          break;
        case 11:
          index += 304;
          break;
        case 12:
          index += 334;
          break;
        default:
          index += 0;
      }
      a[index]++;
      for (int j = 0; j < 10; j++) {
        ss[index][j] = s[i + j];
      }
    }
  }
  int x = 0;
  for (int i = 0; i < 1095; i++) {
    if (x < a[i]) {
      x = index;
    }
  }
  for (int i = 0; i < 10; i++) {
    cout << ss[index][i];
  }
}
