import java.util.*; public class Main { public static void main(String[] args ) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int x = sc.nextInt(); if(N/x/2==1 && N%(x*2)==0){ System.out.println(0); }else if(N%(x*2)==0){ int j=N/(x*2); int y=(j-1)*x; System.out.println(y); }else{ int y=(N/x/2)*x; System.out.println(y); } } }