//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
//#pragma GCC optimize ("trapv")


#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (lli)(x).size()
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace __gnu_pbds;

template <typename T, class compare>
using ordered_set = tree<T, null_type, compare, rb_tree_tag, tree_order_statistics_node_update>;
//usage: ordered_set< el tipo , el comparador> nombre;


int main(){
    fastio;

    set<string> anne,mois;
    map<string,int> m,wyn;
    set<char> valid;

    for(char i='0';i<='9';i++) valid.insert(i);

    anne.insert("2013");
    anne.insert("2014");
    anne.insert("2015");

    mois.insert("01");
    mois.insert("02");
    mois.insert("03");
    mois.insert("04");
    mois.insert("05");
    mois.insert("06");
    mois.insert("07");
    mois.insert("08");
    mois.insert("09");
    mois.insert("10");
    mois.insert("11");
    mois.insert("12");

    m["01"]=31;
    m["02"]=28;
    m["03"]=31;
    m["04"]=30;
    m["05"]=31;
    m["06"]=30;
    m["07"]=31;
    m["08"]=31;
    m["09"]=30;
    m["10"]=31;
    m["11"]=30;
    m["12"]=31;

    string tmr,ot="dd-mm-yyyy"; cin>>tmr;
    string answer; int ke=0;

    /*cout<<endl;
    rep(i,0,sz(tmr)){
        cout<<i<<" -> "<<tmr[i]<<endl;
    }cout<<endl;
*/
    rep(i,0,sz(tmr)-sz(ot)+1){
        if(valid.count(tmr[i]) and valid.count(tmr[i+1]) and valid.count(tmr[i+3]) and valid.count(tmr[i+4])){
            if(valid.count(tmr[i+6]) and valid.count(tmr[i+7]) and valid.count(tmr[i+8]) and valid.count(tmr[i+9])){
                if(tmr[i+2]=='-' and tmr[i+5]=='-');
                else continue;
            }else continue;
        }else continue;
    //    trace(i);
        string mes,an;
        int dia=0;
        dia+=(tmr[i]-'0')*10;
        dia+=(tmr[i+1]-'0');
        mes+=tmr[i+3];
        mes+=tmr[i+4];
        for(int j=i+6;j<i+10;j++) an+=tmr[j];
        //trace(dia,mes,an);
        if(anne.count(an) and mois.count(mes) and m[mes]>=dia){
            string temp;
            for(int j=i;j<i+sz(ot);j++) temp+=tmr[j];
        //    trace(temp);
            wyn[temp]++;
            if(wyn[temp]>ke){
                ke=wyn[temp];
                answer=temp;
            }
        }
    //    cout<<endl;
    }
    cout<<answer<<endl;
    return 0;
}
