#include<bits/stdc++.h> using namespace std; int main() { int n,k,b,c; cin>>n>>k; do { b=n/k; c=n%k; n=n+b; b=(b+c)/k; } while(b=0); cout<<n; }