import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from math import ceil l, k = map(int, read().split()) print((ceil(l / (k * 2)) - 1) * k)