using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); static long[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var p = ReadLine(); var list = new int[p.Length]; for (var i = 0; i < p.Length; ++i) list[i] = p[i] - '0'; WriteLine(Lucky(list) ? "Yes" : "No"); } static bool Lucky(int[] _list) { var list = (int[]) _list.Clone(); if (list.Length == 1) return false; if (list[0] == 1) { for (var i = 1; i < list.Length; ++i) { list[i] -= 6; if (list[i] < 0) { --list[i - 1]; list[i] += 10; } } if (list[0] != 0) return false; for (var i = 1; i < list.Length; ++i) { if (list[i] < 6 || 8 < list[i]) return false; } return true; } else if (list[0] >= 6) { for (var i = 0; i < list.Length; ++i) { list[i] -= 6; if (list[i] < 0) { --list[i - 1]; list[i] += 10; } } var flg = false; for (var i = 0; i < list.Length; ++i) { if (list[i] > 1) flg = true; if (!flg && list[i] != 0 && list[i] != 1) return false; if (flg && list[i] != 6 && list[i] != 7 && list[i] != 8) return false; } return flg; } else return false; } }