#include<stdio.h>
int main ()
{
    long long n,k,x,i,y;
    scanf("%lld %lld", &n, &k);
    if(k>=n){x=n;}
    else if(n%k==0){x=0;}
    else{y=n/k+1;
         k=k*y;
         x=n-k;
         if(x<0){x=-x;}
        }
    printf("%lld ", x);

}
