// 这题完全是面向测试用例开发
#include <cctype>
#include <iostream>
using namespace std;
int main() {
string str1,str2,str3,str4,str;
while (cin >> str) { // 注意 while 处理多个 case
int pointCnt = 0;
bool bisValid = true;
for(auto it : str){
if(it == '.'){
pointCnt ++;
}else if(!isdigit(it)){
bisValid = false;
}
}
if(pointCnt != 3){
bisValid = false;
}
int pos = str.find('.');
str1 = str.substr(0, pos);
str = str.substr(pos + 1);
pos = str.find('.');
str2 = str.substr(0, pos);
str = str.substr(pos + 1);
pos = str.find('.');
str3 = str.substr(0, pos);
str4 = str.substr(pos + 1);
if(str1 == "" || str2 == "" || str3 == "" || str4 == ""){
bisValid = false;
}else if(str1[0] == '0' && str1.length() != 1 ||
str2[0] == '0' && str2.length() != 1 ||
str3[0] == '0' && str3.length() != 1 ||
str4[0] == '0' && str4.length() != 1 ){
bisValid = false;
}
else if(stoi(str1) > 255 || stoi(str2) > 255 ||
stoi(str3) > 255 || stoi(str4) > 255){
bisValid = false;
}else if(stoi(str1) < 0 || stoi(str2) < 0 ||
stoi(str3) < 0 || stoi(str4) < 0){
bisValid = false;
}
if(bisValid){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
}
// 64 位输出请用 printf("%lld")