rt
#include<bits/stdc++.h>
using namespace std;
int n,m,now;
list<int> L;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;++i)
{
L.push_back(i);
}
list<int>::iterator it=L.begin();
while(true)
{
now++;
if(now==m)
{
cout<<*it<<" ";
L.erase(it);
now=0;
}
if(L.empty())
{
break;
}
it++;
if(it==L.end())
{
it=L.begin();
}
}
return 0;
}