N,M =map(int, input().split()) print(abs(N%M))