import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int left = sc.nextInt(); int center = sc.nextInt(); int right = 0; if (left < center) { right = left - 1; } else if (left > center) { right = 2000000000 - left + 1; } System.out.println(right); } }