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