input_line = input().split(' ')
N = int(input_line[0])
K = int(input_line[1])

print(N%K) input_line = input().split(' ') input_line input().split(' ') ().split () input split ' ' N = int(input_line[0]) N int(input_line[0]) int input_line[0] input_line 0 K = int(input_line[1]) K int(input_line[1]) int input_line[1] input_line 1 print(N%K) print N%K N K K = int(input_line[1]) int(input_line[1]) K N = int(input_line[0]) int(input_line[0]) N input_line = input().split(' ') input().split(' ') input_line
input_line = input().split(' ')
N = int(input_line[0])
K = int(input_line[1])

print(N%K)