package com.exam.hw;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan =new Scanner(System.in);
System.out.println(legalIp(scan.nextLine()));
}
public static String legalIp(String ip) {
// TODO Auto-generated method stub
ip=ip.trim();
if(ip.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")){
String[] ipArr=ip.split("\\.");
int ip1=Integer.parseInt(ipArr[0]);
int ip2=Integer.parseInt(ipArr[1]);
int ip3=Integer.parseInt(ipArr[2]);
int ip4=Integer.parseInt(ipArr[3]);
if(ip1<=0 || ip1>=224 ||ip1==127 || ip2<0 || ip2>255 ||
ip3<0 || ip3>255 || ip4<0 || ip4>255 )
return "NO";
if(ip1>=1&&ip1<=126){
if(ip2==ip3&&ip3==ip4){
if(ip2==0||ip2==255)
return "NO";
else
return "YES";
}
else{
return "YES";
}
}else if(ip1>=128 && ip1<=191){
if(ip3==ip4){
if(ip3==0 || ip3==255)
return "NO";
else
return "YES";
}else{
return "YES";
}
}else{
if(ip4==0||ip4==255)
return "NO";
else
return "YES";
}
}
else
return"NO";
}
}