#include<stdio.h>
#include<stdlib.h>
int main()
{
	long long int N,K;
    int s[100],i;
    scanf("%lld %lld",&N,&K);
    s[0] = abs(N-K);
    for(i=1; ; i++)
    {
        s[i] = abs(K-s[i-1]);
        if(s[i]>s[i-1])
        {
            printf("%d\n",s[i-1]);
            return 0;
        }
    }
}
