#include int main(void){ int L, K, n; scanf("%d %d\n", &L, &K); if(L%(2*K)) n = L/(2*K); else n = L/(2*K) - 1; printf("%d\n", n*K); return 0; }