import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] input = new String[1]; int i = 0; while (sc.hasNext()) { input[i] = sc.nextLine(); i++; } System.out.println(solve(input)); sc.close(); } public static long solve(String[] in) { long a = Long.valueOf(in[0].split(" ")[0]); long b = Long.valueOf(in[0].split(" ")[1]); if(a < b){ return a - 1L; }else{ return 2000000000 - b - 1L; } } }