#include int main(){ int L=0,K; scanf("%d %d",&L,&K); while(2*K>L){ L = L - 2*K; } printf("%d",L); }