#include<stdio.h>
#include<stdlib.h>
struct node{
int date;
struct node *next;
};
struct node *head,*p,*q;
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
q=(struct node *)malloc(sizeof(struct node));
q->date=i;
if(i==1)
head=p=q;
else{
p->next=q;
q->next=head;
p=q;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m-1;j++){
p=head;
head=head->next;
}
printf("%d ",head->date);
p->next=head->next;
head=p->next;
}
return 0;
}