import java.util.Scanner; class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str1 = in.next(); String str2 = in.next(); int A = Integer.parseInt(str1); int B = Integer.parseInt(str2); if(A > B) { System.out.println(2000000000 - A - B + 1); } if(A < B) { System.out.println(B - A); } } }