import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L = sc.nextInt(); int K = sc.nextInt(); int nokori=L-K*2; int yuu=0; if(L<=K || L==K*2) yuu=0; else if(nokori<=K*2){ yuu=K; }else{ while(nokori>K*2){ nokori = L-K*2; yuu += K; L=nokori; } } System.out.println(yuu); } }