#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MAX 100
#define MAXI 1000
#define MIN 1
#define MID
int main(void){
  int M,N,K;
  scanf("%d",&N);
  scanf("%d",&K);
  for(int i=0;i<MAX;i++){
    N=abs(N-K);
  }printf("%d",N);
  exit(0);
  }
  