#include int main (void){ int l,k,y; scanf("%d%d",&l,&k); if(l/k == 2 && l%k == 0) y = 0; else y = l/k/2*k; printf("%d",y); return(0); }