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, up) => { if (digit >= P.Length) return true; if (new[] { 0, 6, 7 }.Select(x => x + up).Contains(P[digit])) return dfs(digit + 1, 0); if (digit == 0) return false; if (new[] { 2, 3, 4 }.Select(x => x + up).Contains(P[digit])) return dfs(digit + 1, 1); return false; }; Console.WriteLine(P[0] != 0 && dfs(0, 0) ? "Yes" : "No"); } } }