#include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair Pii; const ll mod = 998244353; int main() { cin.tie(0); ios::sync_with_stdio(false); ll h, a; cin >> h >> a; ll ans = 0; ll slime_health = h; ll slime_num = 1; while (slime_health > 0) { ans += slime_num; slime_health /= a; slime_num *= 2; } cout << ans << endl; return 0; }