program jhfsjk (input, output);
var a, b : integer;
begin
read(a, b);
readln;
c:= (a mod b);
writeln(c)
end.