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