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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H,A;
  cin>>H>>A;
  ll ans=0,t=1;
  while(H>0){
    ans+=t;
    H/=A;
    t*=2;
  }
  cout<<ans<<'\n';
}