#include <bits/stdc++.h>
using namespace std;
int main() {
  int candles, alters, hours = 0, therest = 0;
  cin >> candles >> alters;
  hours = candles;
  while (candles / alters != 0) {
    hours += candles / alters;
    therest = candles % alters;
    candles /= alters;
    candles += therest;
  }
  cout << hours;
  return 0;
}
