#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template void chmin(T &a,T b){ if(a>b){ a=b; } } template void chmax(T &a,T b){ if(a mp; ll h,a; ll f(ll x){ if(x<=0) return 0; if(mp.count(x)) return mp[x]; return mp[x]=1+f(x/a)+f(x/a); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> h >> a; cout << f(h) << '\n'; }