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