#include <bits/stdc++.h>
using namespace std;

int main() {

    string s; cin >> s;
    int n = s.size();
    if(n == 1){
        if(s=="8") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(n == 2) {
        int a = s[0] - '0', b = s[1] - '0';
        if((a * 10 + b) % 8 == 0 || (b * 10 + a) % 8 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    vector<int> cnt(10);
    for(int i = 0; i < n; ++i) {
        ++cnt[s[i] - '0'];
    }
    for(int i = 0; i < 1000; i += 8) {
        int a = i / 100, b = i / 10 % 10, c = i % 10;
        --cnt[a]; --cnt[b]; --cnt[c];
        if(cnt[a] >= 0 && cnt[b] >= 0 && cnt[c] >= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        ++cnt[a]; ++cnt[b]; ++cnt[c];
    }

    cout << "No" << endl;

    return 0;
}
#include <iostream>
using namespace std;
string Save[3][125];
string erase(string n,int index){
	string a,b;
	a=b="";
	for(int i=0;i<index;i++){
		a+=n[i];
	}
	for(int i=index+1;i<n.length();i++){
		b+=n[i];
	}
	return a+b;
}
int main() {
	int c1,c2,c3;
	c1=c2=c3=0;
	for(int i=8;i<1000;i+=8){
		if(to_string(i).length()==3){
			Save[2][c3]=to_string(i);
			c3++;
		}else if(to_string(i).length()==2){
			Save[1][c2]=to_string(i);
			c2++;
		}else{
			Save[0][c1]=to_string(i);
			c1++;
		}
	}
	string S;
	cin>>S;
	string temp;//Temporary S, we need S!
	int find_i;//Finding the # index of the chart
	if(S.length()>=3){//If S has 3 or more digits
		for(int i=0;i<c3;i++){
			temp=S;
			find_i=0;
			for(int j=0;j<temp.length() and find_i<3;j++){
				if(temp[j]==Save[2][i][find_i]){
					find_i++;
					temp=erase(temp,j);
					j=-1;
				}
			}
			if(find_i==3){
				cout<<"Yes";
				break;
			}
			if(i==c3-1){
				cout<<"No";
				break;
			}
		}
	}else if(S.length()==2){//If S has 2 digits
		for(int i=0;i<c2;i++){
			temp=S;
			find_i=0;
			for(int j=0;j<temp.length() and find_i<2;j++){
				if(temp[j]==Save[1][i][find_i]){
					find_i++;
					temp=erase(temp,j);
					j=-1;
				}
			}
			if(find_i==2){
				cout<<"Yes";
				break;
			}
			if(i==c2-1){
				cout<<"No";
				break;
			}
		}
	}else{//If S has 1 digit
		if(S=="8"){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}
}