#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, sum = 0;
  cin >> a >> b;
  sum += a;
  while ((a / b) > 0) {
    if (a % b == 0) {
      sum += a / b;
      a /= b;
    } else {
      sum += a / b;
      a = (a / b) + a % b;
    }
  }
  cout << sum;
}
