#include<iostream>
#include<string>
#include<cmath>
#include<cctype>
#define isyear(x) x%4==0&&x%100!=0 || x%400==0 ? 1:0
int buf[13][2]={{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};
using namespace std;
bool isCorrect(string str1){
if(str1.length()!=18){
return false;
}else{//长度等于18 622425199410163513
int year=(str1[6]-‘0’)*pow(10,3)+(str1[7]-‘0’)*pow(10,2)+(str1[8]-‘0’)*pow(10,1)+(str1[9]-‘0’);
int month=(str1[10]-‘0’)*10+(str1[11]-‘0’);
if(month>12){
return false;
}
int day=(str1[12]-‘0’)*10+(str1[13]-‘0’);
if(buf[month][isyear(year)]>=day&&(str1[17]==’x’||isdigit(str1[17]))){
return true;
}
return false;
}
}
int main(){
string str;
cin>>str;
if(isCorrect(str)){
cout<<“YES”<<endl;
}else{
cout<<“No”<<endl;
}
return 0;
}