import numpy as np
s = list(map(int, input().split()))
l = s[0]

while True:
    tmp = s[0]
    s[0] = s[1]
    s[1] = tmp - s[1]
    s = np.sort(s)[::-1]
    
    if s[0] == s[1]:
        l += s[0]
        break
    else:
        l = l + s[1] * 2

print(l)