#include <iostream>

using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b;
    c = b - a;
    cout<< c - a % c;
    return 0;
}