# div2019-2A - Ball Distribution

n, k = list(map(int, input().rstrip().split()))

print((n % k))
# diverta2019-2A - Ball Distribution

def main():

    n, k = list(map(int, input().rstrip().split()))

    print((n % k))





if __name__ == "__main__":

    main()
# div2019-2A - Ball Distribution
n, k = list(map(int, input().rstrip().split()))
print((n % k))

# diverta2019-2A - Ball Distribution
def main():
    n, k = list(map(int, input().rstrip().split()))
    print((n % k))


if __name__ == "__main__":
    main()

-# div2019-2A - Ball Distribution -n, k = list(map(int, input().rstrip().split())) -print((n % k)) +# diverta2019-2A - Ball Distribution +def main(): +    n, k = list(map(int, input().rstrip().split())) +    print((n % k)) + + +if __name__ == "__main__": +    main()