D1,D2=map(int,input().split()) if D1==D2: print(4) elif D1D2: print(8) elif 2*D1==D2: print(4) else: print(0)