program ideone;
var X, N, Y: integer;
begin
readln(X);
readln(N);
Y := X mod round(exp(ln(10)*N));
writeln(Y);
end.
cHJvZ3JhbSBpZGVvbmU7CnZhciBYLCBOLCBZOiBpbnRlZ2VyOwpiZWdpbgoJcmVhZGxuKFgpOwoJcmVhZGxuKE4pOwoJWSA6PSBYIG1vZCByb3VuZChleHAobG4oMTApKk4pKTsKCXdyaXRlbG4oWSk7CmVuZC4=