#include<stdio.h>
#include<stdlib.h>
struct seqlist{
int data;
struct seqlist *next;
};
int main() {
seqlist *list, *head, *temp;
int n, m, i;
scanf("%d%d",&n,&m);
head = list = (seqlist *)malloc(sizeof(seqlist));
for(i = 1;i <= n;i ++) {
list->data = i;
if(i < n) {
list->next = (seqlist *)malloc(sizeof(seqlist));
list = list->next;
}
}
list->next = head;
while(head != head->next) {
for(i = 1;i < m - 1;i ++) {
head = head->next;
}
temp = head->next;
printf("%d ",temp->data);
head->next = head->next->next;
temp = NULL;
free(temp);
head = head->next;
}
printf("%d",head->data);
return 0;
}