# yukicoder No.333 門松列を数え上げ A, B = map(int, input().split()) M = 2 * (10 ** 9) print(M - A if A > B else A - 1)