#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 2e5 + 5;

int i, n;
string s;

void solve()
{
    cin >> s;
    map<int, int> freq;
    for (char c : s)
    {
        freq[c - '0']++;
    }
    if (sz(s) == 1)
    {
        if (s == "8")
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return;
    }
    if (sz(s) == 2)
    {
        for (i = 16; i < 100; i += 8)
        {
            int a = i / 10, b = i % 10;
            freq[a]--;
            freq[b]--;
            if (freq[a] >= 0 && freq[b] >= 0 && a > 0 && b > 0)
            {
                cout << "Yes" << endl;
                return;
            }
            freq[a]++;
            freq[b]++;
        }
        cout << "No" << endl;
        return;
    }
    for (i = 112; i < 1000; i += 8)
    {
        int a = i / 100, b = (i / 10) % 10, c = i % 10;
        freq[a]--;
        freq[b]--;
        freq[c]--;
        if (a > 0 && b > 0 && c > 0)
        {
            if (freq[a] >= 0 && freq[b] >= 0 && freq[c] >= 0)
            {
                cout << "Yes" << endl;
                return;
            }
        }
        freq[a]++;
        freq[b]++;
        freq[c]++;
    }
    cout << "No" << endl;
}


signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e3 + 5;
long long mod = 1e9 + 7;
const int lim = 700;
const int lg = 19;
const long double eps = 1e-6;
ll a[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("tests.inp", "r")){
        freopen("tests.inp", "r", stdin);
        freopen("tests.out", "w", stdout);
    }
    ll n;
    cin >> n;
    ll mn = 1e9;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        mn = min(a[i], mn);
    }
    unordered_map<ll, ll> mem;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j * j <= a[i] && j <= mn; j++){
            if ((a[i] % j) == 0){
                mem[j] = __gcd(mem[j], a[i]);
                if ((a[i] / j) <= mn){
                    mem[a[i] / j] = __gcd(mem[a[i] / j], a[i]);
                }
            }
        }
    }
    ll ans = 0;
    for (auto j : mem){
        if (j.first == j.second) ans++;
    }
    cout << ans;
}
/*
Ans:

Out:
*/

