using System; using System.Linq; namespace No653 { class Program { static void Main(string[] args) { var P = Console.ReadLine().Reverse().Select(c => c - '0').ToArray(); Func dfs = null; dfs = digit => { if (digit >= P.Length) return false; if (P[digit] == 1 && digit + 1 == P.Length) return true; if (P[digit] == 7 || P[digit] == 8) return P.Skip(digit + 1).All(x => x == 6 || x == 7); if (new[] { 3, 4, 5 }.Contains(P[digit])) return dfs(digit + 1); return false; }; var res = new[] {2, 3, 4}.Contains(P[0]) && P.Length >= 2 && dfs(1); Console.WriteLine(res ? "Yes" : "No"); } } }