line = input().split()
a, b = int(line[0]), int(line[1])
print(a%b) line = input().split() line input().split() ().split () input split a, b = int(line[0]), int(line[1]) a int(line[0]) int line[0] line 0 b int(line[1]) int line[1] line 1 print(a%b) print a%b a b line = input().split() input().split() line b = int(line[0]), int(line[1]) int(line[1]) b a, b = int(line[0]), int(line[1]) int(line[0]) a
line = input().split()
a, b = int(line[0]), int(line[1])
print(a%b)