a,b = map(int,input().split()) num_temp = a // (2*b) num_amari = a % (2*b) print( b*num_temp if not num_amari ==0 else b*(num_temp-1) )