#include<stdio.h>
/*围圈报数*/
void left(int *p,int m,int n)
{
int i,j,count;
i = j = count = 0;
while(count < m-1)
{
if(*(p+i) != 0)
j++;
if(j == n)
{
*(p+i) = 0;
count++;
j = 0;
}
if(++i == m)
i = 0;
}
}
int main(void)
{
int x,y;
scanf("%d%d",&x,&y);
int arr[x];
int i;
for(i=0; i<x; i++)
arr[i] = i+1;
left(arr,x,y);
for(i=0; i<x; i++)
if(arr[i] != 0)
printf("%d
",arr[i]);
return 0;
}