#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string S;
    cin >> S;

    int N = S.size();
    vector<int> cnt(10);
    rep(i, N) { ++cnt[S[i] - '0']; }

    if (N >= 3) {
        for (int i = 14; i * 8 < 1000; ++i) {
            int X = i * 8;
            vector<int> tmp(10);
            while (X > 0) {
                ++tmp[X % 10];
                X /= 10;
            }

            bool ok = true;
            rep(i, 10) {
                if (cnt[i] < tmp[i]) {
                    ok = false;
                    break;
                }
            }

            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } else if (N == 2) {
        for (int i = 2; i * 8 < 100; ++i) {
            int X = i * 8;
            vector<int> tmp(10);
            while (X > 0) {
                ++tmp[X % 10];
                X /= 10;
            }

            bool ok = true;
            rep(i, 10) {
                if (cnt[i] < tmp[i]) {
                    ok = false;
                    break;
                }
            }

            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } else {
        if (S == "8") {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  if (n == 1) {
    if ((s[0] - '0') % 8 == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
    return 0;
  }
  if (n == 2) {
    int a = stoi(s);
    if (a % 8 == 0)
      cout << "Yes\n";
    else {
      reverse(s.begin(), s.end());
      int b = stoi(s);
      if (b % 8 == 0)
        cout << "Yes\n";
      else
        cout << "No\n";
    }
    return 0;
  }
  vector<int> dp(8);
  for (int i = 0; i < n; i++) {
    int x = s[i] - '0';
    x %= 8;
    for (int j = 0; j < 8; j++) {
      for (int k = 0; k < 8; k++) {
        if ((j == k && dp[j] > 1) || ((j != k) && (dp[j] >= 1 && dp[k] >= 1))) {
          vector<int> nums = {x, j, k};
          sort(nums.begin(), nums.end());
          do {
            int cur = (nums[0] * 100) % 8 + (nums[1] * 10) % 8 + (nums[2]) % 8;
            cur %= 8;
            if (cur == 0) {
              cout << "Yes\n";
              return 0;
            }
          } while (next_permutation(nums.begin(), nums.end()));
        }
      }
    }
    dp[x]++;
  }
  cout << "No\n";
  return 0;
}