#include <bits/stdc++.h>
int n,m;
int main()
{
cin >> n >> m;
queue<int>q;
int a = 1;
for (int i = 1; i <= n; i++)q.push(i);
while (!q.empty())
{
if (a==m)
{
cout << q.front()<<" ";
q.pop();
a=1;
}
else
{
q.push(q.front());
q.pop();
a++;
}
}
}