#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
string s,ans;
__int64 sum,sum1;
int m,j,i,dd,mm,yyyy,a[100005],q,max1;
string s1[100005];
main(){
         cin>>s;
         max1=0;
         for(i=0;i<s.size()-9;i++)
         {
            if(s[i+0]!='-')      //d
            if(s[i+1]!='-')      //d
            if(s[i+2]=='-')      //-
            if(s[i+3]!='-')      //m
            if(s[i+4]!='-')      //m
            if(s[i+5]=='-')      //-
            if(s[i+6]!='-')      //y
            if(s[i+7]!='-')      //y
            if(s[i+8]!='-')      //y
            if(s[i+9]!='-')      //y
            {
                dd=(s[i]-'0')*10+s[i+1]-'0';
                mm=(s[i+3]-'0')*10+s[i+4]-'0';
                yyyy=(s[i+6]-'0')*1000+(s[i+7]-'0')*100+(s[i+8]-'0')*10+(s[i+9]-'0')*1;
                if(mm>12){break;}
                if(yyyy<2013 || yyyy>2015) break;
                if(mm==2 && dd>28){break;}
                if((mm==4 || mm==6 || mm==9 || mm==11) && dd>30){break;}
                if(dd>31)break;
                for(q=i;q<=i+9;q++)
                s1[j]+=s[q];
                j++;
            }
         }   
         q=0;
         sort(s1,s1+j);  
         if(j==1) cout<<s1[0]<<endl;else  
                  {
                      q=1;
                      for(i=0;i<j-1;i++)
                      if(s1[i]==s1[i+1])  q++; else if(q>max1){max1=q;q=1;ans+=s1[i];}
                  } 
                                           
         
            
            cout<<ans<<endl;
            return 0;
            }
                      
            
            