import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from math import gcd A,B = map(int, read().split()) g = gcd(A,B) if g > 1: print(-1) else: print((A-1) * (B-1) // 2)