#include <stdio.h>
int n, m, i, j, k;
char s[15];
int main(){
scanf("%s", &s);
if(s[0]<'A' || s[0]>'Z') m = 1;
if(s[7]<'A' || s[7]>'Z') m = 1;//头尾大写字母
for(i=1; i<=6; i++){
if(s[i]<'0' || s[i]>'9') m = 1;
n = n*10 + s[i] - 48;
}//中间6位数字不小于1000000
if(n<100000 || n>999999) m = 1;
if(s[8]) m = 1;//8位字符
if(m) printf("No\n");
else printf("Yes\n");
return 0;
}