#include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int days = n;
int vo_bao = n;
while (vo_bao >= k) {
int bao_moi = vo_bao / k;
days += bao_moi;
vo_bao = vo_bao % k + bao_moi;
}
cout << days << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7CgogICAgaW50IGRheXMgPSBuOwogICAgaW50IHZvX2JhbyA9IG47CgogICAgd2hpbGUgKHZvX2JhbyA+PSBrKSB7CiAgICAgICAgaW50IGJhb19tb2kgPSB2b19iYW8gLyBrOwogICAgICAgIGRheXMgKz0gYmFvX21vaTsKICAgICAgICB2b19iYW8gPSB2b19iYW8gJSBrICsgYmFvX21vaTsKICAgIH0KCiAgICBjb3V0IDw8IGRheXMgPDwgZW5kbDsKICAgIHJldHVybiAwOwp9Cg==