#include <bits/stdc++.h> using namespace std; int main(){ int n,k,d = 0,c = 0; cin >> n >> k; while (n > 0 || d > k){ d = n; c += d; n = 0; n += d / k; d %= k; } cout << c; return 0; }