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