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(); long A = Long.parseLong(str1); long B = Long.parseLong(str2); if(A > B) { System.out.println(2000000000 - A - B); } if(A < B) { System.out.println(B - A); } } }