5 3
 1000 3
 777 17
 4 3
 2 2
 100 4
 10 4
 999 2
 6 4
 1 2
 17 3
 1 4
 26 8
 91 5
 1 3
 1000 2
 20 3
 9 4
 123 5
 1000 1000
 3 2
 3 3
 80 970
 1000 4
 1 1000

7
 1499
 825
 5
 3
 133
 13
 1997
 7
 1
 25
 1
 29
 113
 1
 1999
 29
 11
 153
 1001
 5
 4
 80
 1333
 1

#include <bits/stdc++.h>
using namespace std;
int const GRAY = -2;
int const BLACK = -1;
int const WHITE = 0;
int const INF = 1e8;
long long const INF64 = 1e18;
template <typename T>
void alert(const T& t) {
  cout << t;
  exit(0);
}
int ugcd(int a, int b) { return b ? ugcd(b, a % b) : a; }
int gcd(int a, int b) { return ugcd(a, b) * ((a < 0) ^ (b < 0) ? -1 : +1); }
int lcm(int a, int b) { return abs(a * b) / gcd(a, b); }
int main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;
  int ans = a;
  int c = a;
  while (c >= b) {
    ans += c / b;
    c = c % b + c / b;
  }
  cout << ans;
  return 0;
}
