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