#include "testlib.h" #include using namespace std; typedef long long ll; ll n; int k; ll solve(ll x){ if(x<=k) return x-1; ll y=solve(x-(x+k-1)/k); return y/(k-1)*k+1+y%(k-1); } const ll MAXN=1000000000000000000ll; const int MAXK=10000; int main(int argc, char* argv[]){ registerValidation(argc, argv); n=inf.readLong(1ll, MAXN); inf.readSpace(); k=inf.readInt(2, MAXK); inf.readEoln(); inf.readEof(); cout<