import sys
input = sys.stdin.readline

A,B=map(int,input().split())

if B<0:
    B=-B
    A=-A

print(A%B)