a,b=map(int,input().split()) for r in range(abs(b)): if (a-r)%abs(b)==0: print(r) exit()