import strutils, sequtils, math const D = 2 * 10 ^ 9 let AB = stdin.readLine.split.map parseInt let (A, B) = (AB[0], AB[1]) echo if A < B: A - 1 else: D - A