import java.io.*; import java.util.*; class Main63 { public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); int l = Integer.parseInt(line[0]); int k = Integer.parseInt(line[1]); double d = (double)l / (k * 2), sub = d - (int)d; System.out.println(sub == 0 ? ((int)d - 1) * k : (int)d * k); } }