Var
s:string;
i:integer;
r:boolean;
d,d1:set of char;
begin
d:=['0'..'9','А','B'..'E'];
d1:=['1','3','5','7','9','B','D'];
Write('Введите строку: '); Readln(s);
r:=True;
for i:=1 to Length(s) do begin
if s[i]='.' then break;
if not (s[i] in d) then begin r:=False; break end
end;
if r then r:=(s[i-1] in d1);
if r then Writeln('YES')
else Writeln('NO')
end.