package yukicoder; import java.util.Scanner; public class yukicoder333 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); long[] a = readLineLongArray(sc); long count = 0; if(a[0] < a[1]){ count = a[0] - 2L -a[0] +a[1]; }else{ count = 2000000000L-a[0] -1L+a[0] -a[1]; } System.out.println(count); } protected static long readLineLong(Scanner sc) { return Long.parseLong(sc.nextLine()); } protected static long[] readLineLongArray(Scanner sc) { String split[] = sc.nextLine().split(" "); long ret[] = new long[split.length]; for (int i = 0; i < ret.length; i++) { ret[i] = Long.parseLong(split[i]); } return ret; } protected static int readLineInt(Scanner sc) { return Integer.parseInt(sc.nextLine()); } protected static int[] readLineIntArray(Scanner sc) { String split[] = sc.nextLine().split(" "); int ret[] = new int[split.length]; for (int i = 0; i < ret.length; i++) { ret[i] = Integer.parseInt(split[i]); } return ret; } protected static double readLineDouble(Scanner sc) { return Double.parseDouble(sc.nextLine()); } protected static double[] readLineDoubleArray(Scanner sc) { String split[] = sc.nextLine().split(" "); double ret[] = new double[split.length]; for (int i = 0; i < ret.length; i++) { ret[i] = Double.parseDouble(split[i]); } return ret; } protected static String readLineString(Scanner sc) { return sc.nextLine(); } protected static String[] readLineStringArray(Scanner sc) { return sc.nextLine().split(" "); } }