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