x, y = map(int, input().split()) if x == 0 and y == 0: print(0) elif (x == 1 or y == 1) or x == y: print(1) else: print(2)