#include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) int main(){ ll h , a ; cin >> h >> a ; ll ans = 0 ; ll num = 1 ; while ( h != 0 ) { ans += num ; num *= 2 ; h = h / a ; } cout << ans << endl ; }