#include <iostream>
using namespace std;
int main() {
long long a, b;
cin >> a >> b;
cout << (b-a) - a%(b-a);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cglsb25nIGxvbmcgYSwgYjsKCWNpbiA+PiBhID4+IGI7Cgljb3V0IDw8IChiLWEpIC0gYSUoYi1hKTsgCiAJcmV0dXJuIDA7Cn0=