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