#yuki982 import math a,b=map(int,input().split()) if math.gcd(a,b)>1: print(-1) else: print((a-1)*(b-1)//2)