#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod = 1e9 + 7;
const int N = 1e6 + 4;

int solve()
{
	int n; scn(n);

	string s; cin>>s;

	rep(i, 2, n)
	if(s[i] == '1' and s[i - 1] == '1' and s[i - 2] == '1')
	{
		pri(0); return 0;
	}

	vector<int> v;

	int f = -1, l = -1, cnt = 0, prev = -1;

	rep(i, 0, n)
	if(s[i] == '0')
	{
		cnt++; l = i;

		if(f == -1)
		f = i;

		if(prev != -1 and i - prev - 1 != 2)
		{
			pri(0); return 0;
		}

		prev = i;
	}

	ll val = 10000000000;

	if(n == 1 and s[0] == '1')
	{
		lpri(2 * val); return 0;
	}

	if(l != n - 1)
	cnt++;

	// cout<<cnt<<endl;

	lpri(val - cnt + 1);

	return 0;
}

int main()                  
{
	int t = 1; //scn(t);

	while(t--)
	{
		solve();
	}

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

bool solve(string s){
	int n = s.size();
  	if(n == 1) return s == "8";
  	if(n == 2){
    	if(stoi(s)%8 == 0) return 1;
      	swap(s[0],s[1]);
      	return stoi(s)%8 == 0;
    }
  	
  	vector<int> cnt(10);
    for(char x : s) cnt[x-'0']++;
  	for(int i = 0; i < 1000; i += 8){
		int x = i;
      	vector<int> nc(10);
      	rep(j, 3){
        	nc[x%10]++;
          	x /= 10;
        }
      	bool ok = true;
      	rep(j, 10) if(nc[j] > cnt[j]) ok = false;
      	if(ok) return true;
    }
  	return 0;
}

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

  	puts(solve(s) ? "Yes" : "No");
}