a,b=map(int,input().split()) print(4 if a==b or a==b/2 else 8 if b/2