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