#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i += (s))

const int maxn = 1002;

bool vis[maxn];
int n, a[maxn], cnt[maxn], idx = 0, prime[maxn];

template <size_t N>
void prepare_primes(int& idx, int prime[N], bool vis[N]) {
  memset(vis, false, sizeof(bool) * N);
  range(i, 2, N, 1) {
    if (!vis[i]) {
      prime[idx++] = i;
      range(j, i + i, n, i) vis[j] = true;
    }
  }
}

int main() {
  // freopen("B.txt", "r", stdin);

  prepare_primes<maxn>(idx, prime, vis);

  while (cin >> n) {
    range(i, 0, n, 1) cin >> a[i];

    memset(cnt, 0, sizeof(cnt));
    range(i, 0, n, 1) {
      range(j, 0, idx, 1) {
        if (a[i] % prime[j] == 0) {
          cnt[j] += 1;
        }
      }
    }

    int ans = 1, value = 0;
    range(i, 0, idx, 1) {
      if (value < cnt[i]) {
        value = cnt[i];
        ans = prime[i];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	string s;
	cin >> s;
	int n = s.size();

	vector<int> a(10);
	rep(i, n) {
		a[s[i] - '0']++;
	}

	if (s.size() == 1) {
		if (s == "8") {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	if (s.size() == 2) {
		if ((a[0] == 1 && a[8] == 1) ||
			(a[1] == 1 && a[6] == 1) ||
			(a[2] == 1 && a[4] == 1) ||
			(a[3] == 1 && a[2] == 1) ||
			(a[4] == 1 && a[0] == 1) ||
			(a[4] == 1 && a[8] == 1) ||
			(a[5] == 1 && a[6] == 1) ||
			(a[6] == 1 && a[4] == 1) ||
			(a[7] == 1 && a[2] == 1) ||
			(a[8] == 2) ||
			(a[9] == 1 && a[6] == 1)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}

	int x = -8;
	while (x < 1000) {
		x += 8;
		auto str = std::to_string(x);
		if (str.size() == 1)str.push_back('0');
		if (str.size() == 2)str.push_back('0');
		auto sub = a;
		sub[str[0] - '0']--;
		if (sub[str[0] - '0'] < 0) continue;
		sub[str[1] - '0']--;
		if (sub[str[1] - '0'] < 0) continue;
		sub[str[2] - '0']--;
		if (sub[str[2] - '0'] < 0) continue;
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}




