def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

A, B = MI()

print((-1) ** int(B % A != 0) * A + B) def INT():
    return int(input()) INT return int(input()) int(input()) int input() input def MI():
    return map(int, input().split()) MI return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A, B = MI() A MI() MI B print((-1) ** int(B % A != 0) * A + B) print (-1) ** int(B % A != 0) * A + B (-1) ** int(B % A != 0) * A (-1) ** int(B % A != 0) -1 int(B % A != 0) int B % A != 0 B % A B A 0 A B A, B = MI() MI() A def INT():
    return int(input()) def INT():
    return int(input()) INT def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI def MI():
    return map(int, input().split()) def MI():
    return map(int, input().split()) MI B = MI() MI() B
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

A, B = MI()

print((-1) ** int(B % A != 0) * A + B)