#include <stdio.h>

int main(void) {  
  double N=0, K=0;
  scanf("%lf%lf",&N,&K);

  while (1){
    double dif =N-K;
    if (dif < 0) dif *= -1;

    if (N > dif) N = dif;
    else break;

  }

  printf ("%lf",N);
  
  return 0;
}