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

string s;
int f[10];
int main() {
	ios::sync_with_stdio(0);
	cin >> s;
	memset(f, 0, sizeof(f));
	for(int i = 0; i < s.size(); i++)
		f[s[i] - '0']++;
	if(s.size() == 2) {
		int d1 = (s[0] - '0') * 10 + (s[1] - '0');
		int d2 = (s[1] - '0') * 10 + (s[0] - '0');
		if(d1 % 8 == 0 || d2 % 8 == 0)
			cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	if(s.size() == 1) {
		if(s == "8")
			cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	for(int i = 112; i < 1000; i += 8) {
		int d1 = i / 100;
		int d2 = i / 10 % 10;
		int d3 = i % 10;
		int t[10];
		for(int i = 0; i <= 9; i++)
			t[i] = f[i];
		if(t[d1] > 0) t[d1]--;
		else continue;
		if(t[d2] > 0) t[d2]--;
		else continue;
		if(t[d3] <= 0) continue;
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
// Compile with "(g++) -std=c++11 -Wall -Wextra -Wconversion -Wshadow -Dcychien"
#ifdef cychien
#define debug(...) do {\
	fprintf(stderr, "%s - %d : (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
    _DO(__VA_ARGS__);\
}while(0) 
template<typename I> void _DO(I&&x) {cerr << x << '\n';}
template<typename I, typename ...T> void _DO(I&&x,T&&...tail) {cerr << x << ", "; _DO(tail...);}
#define IOS
#else
#define debug(...)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#endif
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FOR1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define SZ(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const int NF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846264338327950288;

ll mypow(ll a, ll x){
	if (x == 0) return 1;
	if (x == 1) return a;
	ll res = mypow(a, x >> 1);
	res *= res;
	if (x & 1) res *= a;
	return res;
}
set<ll> s;
int main() {
    IOS;
    ll n;
    cin >> n;
    for (ll a = 2; a <= 100000; a++){
    	for (ll b = 2; b <= 40; b++){
    		ld bb = ld(b), aa = ld(a);
    		if (bb * log(aa) <= log((ld)1e18)){
    			ll cc = mypow(a, b);
    			if (cc <= n){
    				s.insert(cc);
				}
			}
		}
	}
	cout << n - SZ(s) << '\n';
    return 0;
}