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