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