#include <iostream>
using namespace std;
int main()
{
int M, T;
cin >> M;
while (cin >> T) {
if (T == 0) break;
if (T % M == 0) {
cout << T / M << endl;
}
else {
cout << M - T % M << endl;
}
}
return 0;
}