#include using namespace std; typedef long long ll; int main() { ll A, B; cin >> A >> B; ll ans; if(A < 0){ ans = A % B + B; if(ans < 0) ans += abs(B); } else{ ans = A % B; } cout << ans << endl; return 0; }