#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define popcnt __builtin_popcount using ll = long long; using pii = pair; using vi = vector; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const ll inf = 1e16; int a[20005]; bool check(int n) { if (a[0] == 6 || a[0] == 7) { rep(i, n) if (a[i] != 6 && a[i] != 7) return false; return true; } if (a[0] == 2 || a[0] == 3 || a[0] == 4) { bool move = true; for (int i = 1; i < n - 1; i++) { if (move) { if (a[i] != 3 && a[i] != 4 && a[i] != 5) { if (a[i] == 7 || a[i] == 8) move = false; else return false; } } else { if (a[0] != 6 && a[0] != 7) return false; } } if (move) { if (a[n - 1] == 1) return true; } else { if (a[n - 1] == 7 || a[n - 1] == 6) return true; } } return false; } int main() { string s; cin >> s; int n = s.size(); rep(i, n) a[i] = s[n - 1 - i] - '0'; if (check(n)) puts("Yes"); else puts("No"); return 0; }