#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using uint=unsigned int;
using ull=unsigned long long;
const ll LL_MAX=LLONG_MAX; 

class union_find{
private:
  vector<ll> par;
  vector<ll> siz;
  
public:
  union_find(ll n) : par(n),siz(n,1LL){
    for (ll i=0;i<n;i++) par[i]=i;
  }
  
  ll root(ll x){
    ll i=x;
    queue<ll> line;
    while(i!=par[i]){
      line.push(i);
      i=par[i];
    }
    ll l=line.size();
    for (ll j=0;j<l;j++){
      par[line.front()]=i;
      line.pop();
    }
    return i;
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
  
  bool unite(ll x,ll y){
    x=root(x);
    y=root(y);
    if (x==y) return false;
    if (size(x)<size(y)){
      par[x]=y;
      siz[y]+=siz[x];
    }
    else{
      par[y]=x;
      siz[x]+=siz[y];
    }
    return true;
  }
  
  bool same(ll x,ll y){
    if (root(x)==root(y)) return true;
    else return false;
  }
};

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
void outl(T x){
  cout << x << endl;
}
template < >
void outl<int>(int x){
  printf("%d\n",x);
}
template < >
void outl<double>(double x){
  printf("%.16lf\n",x);
}
template < >
void outl<char>(char x){
  printf("%c\n",x);
}
template < >
void outl<string>(string x){
  printf("%s\n",x.c_str());
}
template < >
void outl<uint>(uint x){
  printf("%u\n",x);
}
template < >
void outl<ll>(ll x){
  printf("%lld\n",x);
}
template < >
void outl<ull>(ull x){
  printf("%llu\n",x);
}
void outl(){
  printf("\n");
}

template <typename T>
void out(T x){
  cout << x << flush;
}
template < >
void out<int>(int x){
  printf("%d",x);
}
template < >
void out<char>(char x){
  printf("%c",x);
}
template < >
void out<double>(double x){
  printf("%.16lf",x);
}
template < >
void out<string>(string x){
  printf("%s",x.c_str());
}
template < >
void out<uint>(uint x){
  printf("%u",x);
}
template < >
void out<ll>(ll x){
  printf("%lld",x);
}
template < >
void out<ull>(ull x){
  printf("%llu",x);
}

void outyes(){
  printf("Yes\n");
}
void outno(){
  printf("No\n");
}

void outyn(bool x){
  if (x) printf("Yes\n");
  else printf("No\n");
}

void outsp(){
  printf(" ");
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

template <typename T>
T npr(T x,T y){
  T loop=max(x-y,y),ans=1;
  for (T i=loop;i<=x;i++){
    ans*=i;
  }
  return ans;
}//xPy

template <typename T>
T ncr(T x,T y){
  T loop=min(x,x-y),ans=npr(x,y);
  for (T i=1;i<=loop;i++){
    ans/=i;
  }
  return ans;
}//xCy

template <typename T>
T fac(T x){
    if (x==1) return 1;
    return x*fac(x-1);
}

void div1(ll &x) {
    x%=1000000007;
}

ll mypow(ll x,ll n){
    ll ans=1;
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
        }
        x*=x;
    }
    return ans;
}

ll divpow(ll x,ll n){
    ll ans=1;
    div1(x);
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
            div1(ans);
        }
        x*=x;
        div1(x);
    }
    return ans;
}

int main(){
    ll n=in,k=in;
    for (int i=0;i<k;i++){
        if (n%200==0) n/=200;
        else n=n*1000+200;
    }
    outl(n);
}
///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 3e5 + 10;
ll n, cnt;
string s, t;
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    /*
    cin >> n >> s >> t;
    for(int i = 0; i < n; i ++){
        cnt += (s[i] == '0');
        cnt -= (t[i] == '0');
    }
    if(cnt != 0){
        return cout << -1, 0;
    }
    */
    cin >> n;
    ll ans = n;
    for(int i = 0; (1LL << i) <= n; i ++){
        ll b = i, val = (1LL << i);
        ll a = n / val, c = n - a * val;
        ans = min(ans, a + b + c);
    }
    cout << ans << '\n';
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N
