// Arup Guha
// 11/13/2015
// Solution to UCF 1987 HS Contest Problem: Mind Your P's and Q's

import java.util.*;

public class josephus {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		while (stdin.hasNext()) {

			int n = stdin.nextInt();
			int skip = stdin.nextInt();

			// Create original list.
			ArrayList<Integer> list = new ArrayList<Integer>();
			for (int i=1; i<=n; i++)
				list.add(i);

			int j = 0;
			for (int i=0; i<n; i++) {

				// Skip the correct spots.
				for (int k=0; k<skip-1; k++)
					j = (j+1)%list.size();

				// Print and remove.
				System.out.printf("%5d", list.get(j));
				list.remove(j);
			}
			System.out.println();
		}
	}
}