D1,D2=map(lambda d:(int(d))**0.5,input().split()) print(4 if D1==D2 or round(D1,5)==round(D2/2**0.5,5) else 8 if D1round(D2/2**0.5,5) else 0)