package yukicorder; import java.util.Scanner; public class No333 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = 0; if(b>a){ c = b - 2; }else if(a>b){ c = 2000000000 - b - 1; } System.out.println(c); } }