#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll h, a; cin >> h >> a; function rec = [&](ll v) -> ll { if(v <= 0) return 0; return 2 * rec(v / a) + 1; }; cout << rec(h) << '\n'; }