约瑟夫环
using namespace std;
int main()
{
int n,k;
cin >> n >> k;
queue<int> peo;
for(int i = 1;i <= n;i++)
{
peo.push(i);
}
int cnt = 0;
while(peo.size() != 1)
{
int name = peo.front();
cnt++;
if(cnt == k)
{
peo.pop();
cnt = 0;
continue;
}
peo.pop();
peo.push(name);
}
cout << peo.back();
return 0;
}