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; while(true){ if(L>K*2){ L-=K*2; ans+=K; } else{ ans+=L; break; } } System.out.println(ans); }}