import math A,B=map(int,input().split()) if math.gcd(A,B)!=1: ans=-1 else: ans=(A-1)*(B-1)//2 print(ans)