#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = atcoder::static_modint<998244353>;
// using mint = atcoder::static_modint<1000000007>;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<(int)n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};


ll solve_posi(__int128_t x,__int128_t n){
    if(n*(n+1)/2<=x){
        return x-(n+1)*n/2;
    }

    __int128_t L=0,R=x;
    while(R-L>1){
        __int128_t mid=(L+R)/2;
        if(x-mid*(mid+1)/2<=0)R=mid;
        else L=mid;
    }
    // cout << (ll)L << " " << (ll)R;

    __int128_t x_R=x-R*(R+1)/2;
    if((n-R)%2==0){
        __int128_t ans=x_R-(n-R)/2;
        return ans;
    }
    else{
        __int128_t ans=x_R+R+1+(n-R)/2;
        return ans;
    }
}

ll solve_nega(__int128_t x,__int128_t n){
    assert(false);
    if(x+n*(n+1)/2<=0){
        return x+(n+1)*n/2;
    }

    __int128_t L=0,R=x;
    while(R-L>1){
        __int128_t mid=(L+R)/2;
        if(x+mid*(mid+1)/2>0)R=mid;
        else L=mid;
    }
    // cout << (ll)L << " " << (ll)R;

    __int128_t x_R=x+R*(R+1)/2;
    if((n-R)%2==0){
        __int128_t ans=x_R+(n-R)/2;
        return ans;
    }
    else{
        __int128_t ans=x_R-R-1-(n-R)/2;
        return ans;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x,n;cin >> x >> n;
    if(x==0){
        if(n%2==0)cout << -n/2;
        else cout << (n+1)/2;
    }
    else if(x>0)cout << solve_posi(x,n);
    else cout << solve_nega(x,n);
}