#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet
{
    #define mod 1145141919
	#define F(i,l,r) for(int i=l;i<=r;++i)
	#define D(i,r,l) for(int i=r;i>=l;--i)
	#define Fs(i,l,r,c) for(int i=l;i<=r;c)
	#define Ds(i,r,l,c) for(int i=r;i>=l;c)
	#define MEM(x,a) memset(x,a,sizeof(x))
	#define FK(x) MEM(x,0)
	#define Tra(i,u) for(int i=G.st(u),v=G.to(i);~i;i=G.nx(i),v=G.to(i))
	#define p_b push_back
	#define sz(a) ((int)a.size())
	#define all(a) a.begin(),a.end()
	#define iter(a,p) (a.begin()+p)
	#define PUT(a,n) F(i,1,n) printf("%d ",a[i]); puts("");
	int I() {char c=getchar(); int x=0; int f=1; while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar(); while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return ((f==1)?x:-x);}
	template <typename T> void Rd(T& arg){arg=I();}
	template <typename T,typename...Types> void Rd(T& arg,Types&...args){arg=I(); Rd(args...);}
	void RA(int *p,int n) {F(i,1,n) *p=I(),++p;}
	char a[10];
    void Input()
    {
        scanf("%s",a);
    }
    int n=4; int C[15][15];
    int must,may;
    int f[15];
    int qpow(int a,int b,int m=mod) {int r=1; while(b) {if (b&1) r=r*a%m; a=a*a%m,b>>=1;} return r;}
    void Sakuya()
    {
        C[0][0]=1;
        F(i,1,10)
        {
            C[i][0]=1;
            F(j,1,i)
            {
                C[i][j]=C[i-1][j]+C[i-1][j-1];
            }
        } 
        
        must=may=0;
        F(i,0,9)
        {
            if (a[i]=='o') ++must;
            if (a[i]=='?') ++may;
        }
        f[0]=qpow(may,n);
        F(i,1,must)
        {
            f[i]=qpow(may+i,n);
            F(j,0,i-1) f[i]-=C[i][j]*f[j];
        }
        printf("%d\n",f[must]);
    }
    void IsMyWife()
    {
        Input();
        Sakuya();
    }
}
#undef int //long long
int main()
{
    Flandre_Scarlet::IsMyWife();
    getchar();
    return 0;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
int a[11];

int main()
{
    string s;
    cin>>s;
    memset(a,0,sizeof a);
    for(int i=0; i<s.size(); i++)
    {
        int k=s[i]-'0';
        a[k]++;
    }
    if(s.size()>=3)
    {
        for(int i=100; i<=999; i++)
        {
            int x,y,z;
            x=i%10;
            y=i/10%10;
            z=i/100%10;
            if(x==y&&x==z)
            {
                if(a[x]>=3)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else if(x==y)
            {
                if(a[x]>=2&&a[z]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else if(y==z)
            {
                if(a[x]>=1&&a[z]>=2)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else
            {
                if(a[x]>=1&&a[z]>=1&&a[y]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    else if(s.size()==2)
    {
        for(int i=10; i<=99; i++)
        {
            int x=i%10;
            int y=i/10;
            if(x==y)
            {
                if(a[x]>=2)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else
            {
                if(a[x]>=1&&a[y]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    else
    {
        if(a[8])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}
