using System; using System.Data; using System.Linq; public class Program { static void Main() { string str = Console.ReadLine(); if ((str.Last() != '2' && str.Last() != '3' && str.Last() != '4') || str.Length <= 1) { Console.WriteLine("No"); return; } str = str.Remove(str.Length - 1, 1); bool isLucky = false; if (str.First() == '1') { isLucky = !str.Skip(1).SkipWhile(p => p == '3' || p == '4' || p == '5').Any(); } else if (str.First() != '8' && str.SkipWhile(p => p != '8').Skip(1).Any()) { isLucky = str.TakeWhile(p => p != '8').All(p => p == '6' || p == '7') && !str.SkipWhile(p => p != '8').Skip(1).SkipWhile(p => p == '3' || p == '4' || p == '5').Any(); } else if (str.SkipWhile(p => p == '6' || p == '7').Any()) { isLucky = !str.SkipWhile(p => p == '6' || p == '7').SkipWhile(p => p == '3' || p == '4' || p == '5').Any() && str.TakeWhile(p => p == '6' || p == '7').LastOrDefault() == '7'; } Console.WriteLine(isLucky ? "Yes" : "No"); } }