# -*- coding:utf-8 -*- if __name__ == '__main__': l, k = map(int, input().split()) c = int(l / (k * 2)) print(k * (c - 1 if l % (k * 2) == 0 else c))