#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
typedef long long ll;
typedef long long unsigned llu;
typedef vector<int> vi;
typedef pair<int, int> pi;

#ifdef _DEBUG
ifstream fin("..\\date.in");
#endif

vi v = {112, 128, 136, 144, 152, 168, 176, 184, 192, 216, 224, 232, 248, 256, 264, 272,
        288, 296, 312, 328, 336, 344, 352, 368, 376, 384, 392, 416, 424, 432, 448,
        456, 464, 472, 488, 496, 512, 528, 536, 544, 552, 568, 576, 584, 592, 616, 624,
        632, 648, 656, 664, 672, 688, 696, 712, 728, 736, 744, 752, 768, 776, 784, 792,
        816, 824, 832, 848, 856, 864, 872, 888, 896, 912, 928, 936, 944, 952, 968, 976,
        984, 992};

void solve() {
    string s, t;
    llu poz1, poz2, poz3;
    cin >> s;
    if (s.length() == 1) {
        if (s == "8")
            cout << "Yes";
        else
            cout << "No";
        return;
    } else if (s.length() == 2) {
        if (s == "16" || s == "24" || s == "32" || s == "48" || s == "56" || s == "64" || s == "72" ||
            s == "88" || s == "96" || s == "61" || s == "42" || s == "23" || s == "84" || s == "65" || s == "46" || s == "27" || s == "69")
            cout << "Yes";
        else cout << "No";
        return;
    } else {
        for (int i : v) {
            t = to_string(i);
            poz1 = s.find(t[0]);
            if (poz1 == string::npos)
                continue;
            if (t[1] == t[0]) {
                poz2 = s.find(t[1], poz1 + 1);
                if (poz2 == string::npos)
                    continue;
            } else {
                poz2 = s.find(t[1]);
                if (poz2 == string::npos)
                    continue;
            }
            if (t[2] == t[1]) {
                poz3 = s.find(t[2], poz2 + 1);
                if (poz3 == string::npos)
                    continue;
            } else if (t[2] == t[0]) {
                poz3 = s.find(t[2], poz1 + 1);
                if (poz3 == string::npos)
                    continue;
            } else {
                poz3 = s.find(t[2]);
                if (poz3 == string::npos)
                    continue;
            }
            cout << "Yes";
            return;
        }
        cout << "No";
        return;
    }

}

int main() {
    int t;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
//const int mod = 998244353;

int main()
{
    ll n;
    cin >> n;
    ll ans = LINF;
    for(ll i = 0; i < 61; i++){
        if((1ll<<i) > n) continue;
        ll j = n/(1LL<<i);
        ll k = n - j*(1ll<<i);
        ans = min(ans, i + j + k);
    }
    cout << ans << endl;
    return 0;
}
