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