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