#include <iostream>
#include <cctype>
#include <vector>
using namespace std;
//筛选条件有点多
int main() {
string s;
while (getline(cin, s)) {
int len = s.length();
vector<string> str(10,"");//不要设4,有时可不仅仅是4段,够用就好
int k = 0;
for(int i = 0; i < len; i++){
if(s[i] == '.') {//如果是.则str下标++
k++;
i++;//避开下个检查非数字,若下个是 . 也是非法IP
}
if( !isdigit(s[i])){//很坑,开始以为只有数字和点
cout << "NO" << endl;
return 0;
}else{
str[k] += s[i];//分成字符串段方便检验
}
}
if(k != 3){//如果.少于或多余3都是非法
cout << "NO" << endl;
return 0;
}
for(int i = 0 ; i <= k; i++){
int l = str[i].length();
if(str[i] == "" || l > 3){//有.无数或者数位超过3位
cout << "NO" << endl;
return 0;
}else{
if(l > 1 && str[i][0] == '0'){//当一位数以上0在首位
cout << "NO" << endl;
return 0;
}else{
int num = 0;
for(int j = 0; j < l; j++){
num = num * 10 + (str[i][j] - '0');
if(num > 255){//当数超过255(无符号数,不用管负数)
cout << "NO" << endl;
return 0;
}
}
}
}
}
cout << "YES" << endl;
}
}
// 64 位输出请用 printf("%lld")