#include using namespace std; int main() { int S, K; cin >> S >> K; cout << (S % K) << endl; }