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