A,B=list(map(int,input().split())) for q in range(-int(1e2), int(1e2)+1): if q==0:continue for r in range(abs(B)+1): if A==B*q+r: print(r) exit(0)