#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include //#include #include #include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vi; typedef vector vll; typedef pair pii; int main() { cin.tie(0); ios::sync_with_stdio(false); int S, K; cin >> S >> K; cout << S%K << endl; return 0; }