x,y=map(int,input().split()) if x==y==0: print(0) elif x*y*(x-y)*(x+y)==0: print(1) else: print(2)