import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int x = 0; while(x < N){ x = sc.nextInt(); if(N - x > K)x += K; else if(N - x < K)x += N - x - 1; if(N - x == 1){ ++x; System.out.println(x); break; } System.out.println(x); } } }