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;
char to_upper(char x) {
  if (97 <= int(x) && int(x) <= 126)
    return char(x - 32);
  else if (65 <= int(x) && int(x) <= 90)
    return x;
}
char to_lower(char x) {
  if (97 <= int(x) && int(x) <= 126)
    return x;
  else if (65 <= int(x) && int(x) <= 90)
    return char(x + 32);
}
int numerize(char x) {
  if (48 <= int(x) && int(x) <= 57)
    return int(x - '0');
  else if (97 <= int(x) && int(x) <= 126)
    return int(x - 96);
  else if (65 <= int(x) && int(x) <= 90)
    return int(x - 64);
}
bool isect(int l1, int r1, int l2, int r2) {
  pair<int, int> p1, p2;
  p1 = make_pair(l1, r1);
  p2 = make_pair(l2, r2);
  if (p1 > p2) swap(p1, p2);
  if (p2.first <= p1.second)
    return true;
  else
    return false;
}
long long fexp(long long num1, long long num2, long long MOD) {
  if (num2 == 0)
    return 1;
  else if (num2 == 1)
    return num1;
  else {
    long long temp = fexp(num1, num2 / 2, MOD);
    long long res = ((temp % MOD) * (temp % MOD)) % MOD;
    if (num2 % 2 == 1) res = ((res % MOD) * (num1 % MOD)) % MOD;
    return res;
  }
}
long long invmod(long long num, long long MOD) {
  return fexp(num, MOD - 2, MOD);
}
long long gcd(long long num1, long long num2) {
  if (num1 < num2) swap(num1, num2);
  long long num3 = num1 % num2;
  while (num3 > 0) {
    num1 = num2;
    num2 = num3;
    num3 = num1 % num2;
  }
  return num2;
}
long long lcm(long long num1, long long num2) {
  return (long long)(num1 / gcd(num1, num2)) * num2;
}
int a, b, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> a >> b;
  while (a > 0) {
    ans += a;
    int burn = a;
    a = burn / b;
    burn -= a * b;
  }
  cout << ans << '\n';
}
