#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int A,B; cin >> A >> B; if(B < 0) A *= -1,B *= -1; A %= B; A += B; A %= B; cout << A << endl; }