n, m = map(int, input().split())
nm = n * m

ans = 0
if m <= n:
    n1 = True
    m1 = False
else:
    n1 = False
    m1 = True
while n != 1 or m != 1:
    if n1:
        ans += nm // (n * m) * (n * m)
        n -= 1
        if n <= m:
            n1 = False
            m1 = True        
    else:
        ans += nm // (n * m)  * (n * m)
        m -= 1
        if n >= m:
            n1 = True
            m1 = False
        
print(ans + nm)