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