package no257; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = 0; int k = sc.nextInt(); if ((n - 1) % (k + 1) == 0) { System.out.println(0); x = sc.nextInt(); } while(true) { System.out.println(n - 1 - (n - 1 - x) / (k + 1) * (k + 1)); x = sc.nextInt(); if (x >= n) { break; } } } }