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