#include using namespace std; using ll = long long; int main(){ ll H,A; cin >> H >> A; ll ans = 0; ll slimes = 1; while(H > 0){ ans += slimes; slimes *= 2; H /= A; } cout << ans << endl; }