#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); long long H, A, temp; long long ans = 0; map> slimes; cin >> H >> A; slimes.emplace(H, 1); while (!slimes.empty()) { temp = slimes.begin()->first / A; if (temp != 0) slimes[temp] += slimes.begin()->second * 2; ans += slimes.begin()->second; slimes.erase(slimes.begin()); } cout << ans << '\n'; return 0; }