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