#include <bits/stdc++.h>
using namespace std;
int visited[2000];
int convert(char a) { return (int)a - 48; }
int main() {
  string input;
  cin >> input;
  int d, m, y;
  int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int count = 0;
  vector<int> ans;
  for (int i = 0; i + 10 < input.size(); i++) {
    string temp;
    bool flag = true;
    for (int j = 0; j < 10; j++) {
      if ((j == 2 || j == 5) && input[i + j] != '-') {
        flag = false;
        break;
      }
      temp += input[i + j];
    }
    if (flag) {
      d = convert(temp[0]) * 10;
      d += convert(temp[1]);
      m = convert(temp[3]) * 10;
      m += convert(temp[4]);
      y = convert(temp[6]) * 1000;
      y += convert(temp[7]) * 100;
      y += convert(temp[8]) * 10;
      y += convert(temp[9]);
      if (m <= 12) {
        if (d <= month[m - 1])
          ;
        {
          if (y >= 2013 && y <= 2015) {
            visited[(y - 2013) * 372 + (m - 1) * 31 + d - 1]++;
            count++;
          }
        }
      }
    }
  }
  int j;
  int maxi = 0;
  for (int i = 1200; i >= 0; i--) {
    if (visited[i] != 0) {
      if (maxi < visited[i]) {
        maxi = visited[i];
        j = i;
      }
    }
  }
  y = (j / 372) + 2013;
  j -= (y - 2013) * 372;
  m = j / 31;
  j -= m * 31;
  d = j;
  printf("%02d-%02d-%04d\n", d, m, y);
}
