import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] str = reader.readLine().split(" "); int N = Integer.parseInt(str[0]); int K = Integer.parseInt(str[1]); if (N % 2 == 1) { int ans = Math.min(N, 1+K); System.out.println(ans); } else { int ans = Math.min(N/2, 1+K); System.out.println(ans); } } }