s, k = io.read("*n", "*n") print(s % k)