let str;
while ((str = readline())) {
  let rr = /^((0)|(1\d{2})|(2[0-4]\d)|(25[0-5])|([1-9]\d?))$/;
  let arr = str.split('.')
  print(arr.length === 4 && arr.every(el => rr.test(el)) ? "YES" : "NO");
}