def gcd(a, b): while b: a, b = b, a%b return a A, B = map(int, input().split()) if gcd(A, B)!=1: print(-1) else: print((A-1)*(B-1)//2)