n1, n2 = map(int, input().split()) s = min(n1, n2) b = max(n1, n2) if s >= 4: print(s - 4) elif b >= 4*2: print(b - 4) else: print(s + 4)