/*
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
http://www.cnblog.com/MiYu
Author By : MiYu
Test : 1
Program : 1555
*/
#include <iostream>
using namespace std;
int main ()
{
int M,K;
while ( cin >> M >> K && M | K )
{
int tag = 0,day = 0;;
while ( M -- )
{
tag ++;
day ++;
if ( tag == K )
{
M ++;
tag = 0;
}
}
cout << day << endl;
}
return 0;
}