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