import sys input=lambda: sys.stdin.readline().rstrip() n,m=map(int,input().split()) if m>=n: print(1) elif n%2==0 and m>=n//2+1: print(2) else: print(0)