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