import math a,b=map(int,input().split()) ans=0 if math.sqrt(a)==math.sqrt(b/2): print(4) exit() elif math.sqrt(a)>math.sqrt(b/2): print(8) exit() else: print(0) exit()