#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, big = 1e6 + 3;
string n;
int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int date[40][15][10];
int main() {
  memset(date, 0, sizeof date);
  getline(cin, n);
  cout << n << " " << n.size() << endl;
  int dd, mm, yy;
  for (int i = 0; i < n.size(); i++) {
    dd = -1;
    mm = -1;
    yy = -1;
    if (n[i] == '-') {
      if (i + 7 < n.size() && i > 0) {
        if (n[i - 2] != '-' && n[i - 1] != '-') {
          dd = (n[i - 2] - '0') * 10 + (n[i - 1] - '0');
        }
        if (n[i + 2] != '-' && n[i + 1] != '-' && n[i + 3] == '-') {
          mm = (n[i + 1] - '0') * 10 + (n[i + 2] - '0');
        }
        if (n[i + 4] != '-' && n[i + 5] != '-' && n[i + 6] != '-' &&
            n[i + 7] != '-') {
          yy = (n[i + 4] - '0') * 1000 + (n[i + 5] - '0') * 100 +
               (n[i + 6] - '0') * 10 + n[i + 7] - '0';
        }
        cout << dd << mm << yy << endl;
      }
      if (yy != -1) {
        i += 5;
      }
      if (mm > 0 && mm < 13 && dd > 0 && dd <= mon[mm] && yy >= 2013 &&
          yy <= 2015) {
        date[dd][mm][yy - 2013]++;
        cout << dd << mm << yy << endl;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j < 13; j++) {
      for (int z = 1; z <= mon[j]; z++) {
        if (date[z][j][i] > ans) {
          ans = date[z][j][i];
          dd = z;
          mm = j;
          yy = i + 2013;
        }
      }
    }
  }
  cout << dd << '-' << mm << '-' << yy << endl;
  return 0;
}
