import java.util.*; public class ok{ public static void main(String[] args) { Scanner sc=new Scanner (System.in); int L=sc.nextInt(); int K=sc.nextInt(); int ans=0; if(L%(K*2)!=0)ans=L/(K*2); else ans=L/(K*2)-1; ans*=K; System.out.println(ans); }}