#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< >(b,vector(c,d)) #define vvv(a,b,c,d,e) vector > >(b,vv(a,c,d,e)) using ll = long long; using pii = pair; using vi = vector; using vll = vector; // i<=20000 // dp[i桁まで見た][繰り上がりした][0,1,2個の値を使う] int dp[20004][2][3]; int dig[2] = { 6,7 }; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); string p; cin >> p; each(c, p)c -= '0'; int N = sz(p); dp[0][0][2] = 1; rep(i, N) { int d = p[N-1-i]; rep(up, 2) { rep(num, 3) { int cur = dp[i][up][num]; if (!cur)continue; if (num == 2) { for (int x : dig)for (int y : dig) { int dd = (x + y + up) % 10; int nextUp = (x + y + up) / 10; if (dd == d) { dp[i + 1][nextUp][2] = 1; } } } if (num <= 2 && i > 0) { for (int x : dig) { int dd = (x + up) % 10; int nextUp = (x + up) / 10; if (dd == d) { dp[i + 1][nextUp][1] = 1; } } } if (up == d && i > 0) { dp[i + 1][0][0] = 1; } } } } string ans = "No"; rep(num, 2)if (dp[N][0][num])ans = "Yes"; cout << ans << endl; }