import sys input = sys.stdin.readline A,B=map(int,input().split()) if B<0: B=-B A=-A x=A%B print((-x+B)%B) else: print(A%B)