#!/usr/bin/python3 a, b = map(int, input().split()) assert a != b if a < b: res = b - 2 else: res = int(2e9) - (b+1) print(res)