#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool solve(const string& s, int i, int carry, bool isBoth) { int n = s.size(); int a = s[i] - '0' - carry; if(i == 0) return a == 0 || a == 6 || a == 7; if(isBoth && (a == 2 || a == 3 || a == 4) && solve(s, i-1, 1, true)) return true; if(i != n - 1 && (a == 6 || a == 7) && solve(s, i-1, 0, isBoth)) return true; return false; } int main() { string s; cin >> s; int n = s.size(); if(solve(s, n-1, 0, true)) cout << "Yes" << endl; else cout << "No" << endl; return 0; }