#include<stdio.h>
#include<stdlib.h>
struct per{
struct per *nxt;
struct per *prev;
int num;
};
void main(){
int i,n,m;
scanf("%d %d",&n,&m);
struct per *p,*head;
head = (struct per*)malloc(sizeof(struct per));
p = head;
head->nxt = NULL;
head->prev = NULL;
head->num = 1;
for(i = 2;i <= n;i++){
struct per *tmp = (struct per*)malloc(sizeof(struct per));
tmp->prev = p;
tmp->nxt = NULL;
tmp->num = i;
p->nxt =tmp;
p = tmp;
}
p->nxt = head;
head->prev = p;
p = head;
while(p->nxt!=p){
for(i = 0;i < m-1;i++){
p = p->nxt;
}
printf("%d ",p->num);
p->prev->nxt = p->nxt;
p->nxt->prev = p->prev;
p = p->nxt;
}
printf("%d",p->num);
}