def main(): L, K = map(int, input().split()) haruka = 0 yu = 0 while L > 0: if L <= 2*K: haruka += L L = 0 else: haruka += K yu += K L -= 2*K print(yu) if __name__ == "__main__": # {{{ try: import test test.test() except: main() # }}}