import java.util.Scanner; class no333{ public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int a=stdIn.nextInt(),b=stdIn.nextInt(); System.out.print(a>b?1999999999-b:b-2); } }