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

int main (){
    ll n, a, b, c;
    cin >> n;
    ll two = 1;
    ll ans=100100100100100100;
    rep(i, 60){       
        a = n/two;
        c = n-a*two;
        if(ans>a+i+c) ans=a+i+c;
        if(n<two) break;
        two *= 2;
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
#define ll long long

const ll OO = 0x3f3f3f3f;
const ll mod =   1e9 + 7;
const double pi = 3.14159265359;

//freopen("window.in", "r", stdin);
//freopen("output.out", "w", stdout);
void skrrrt() {
    ios_base::sync_with_stdio(0), cin.tie(0);
}
//###############################Spaggetti############################
bool ispal(string a){
    for(int i=0,j=a.size()-1;i<=j;i++,j--){
        if(a[i]!=a[j])return 0;
    }
    return 1;
}
int main(){
    skrrrt();
    string a;
    cin>>a;
    string tmp="";
    int n=(int)a.size();
    int ind=n-1;
    for(int i=n-1;i>=0;i--){
        if(a[i]!='0'){
            ind=i;
            break;
        }
    }
    for(int i=0;i<=ind;i++)tmp+=a[i];
    if(ispal(tmp))cout<<"Yes";
    else cout<<"No";


}