#include #include #include #include #include #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; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = s.length(); if(n == 1 || (s.back() != '2' && s.back() != '3')){ cout << "No\n"; return 0; } reverse(begin(s), end(s)); vector>> dp(n + 1, vector>(2, vector(2))); dp[1][1][0] = true; for(int i = 1; i < n; ++i){ int num = s[i] - '0'; for(int j = 0; j < 2; ++j){ if(dp[i][j][0]){ for(int x = 6; x <= 7; ++x){ for(int y = 6; y <= 7; ++y){ if((x + y + j) % 10 == num){ dp[i + 1][(x + y + j) / 10][0] = true; } } dp[i + 1][(x + j) / 10][1] = true; } } if(dp[i][j][1]){ for(int x = 6; x <= 7; ++x){ if((x + j) % 10 == num){ dp[i + 1][(x + j) / 10][1] = true; } } } } } cout << ((dp[n][0][0] || dp[n][0][1]) ? "Yes\n" : "No\n"); return 0; }