#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, l;
    cin >> n >> l;
    vector<int> d(n);
    for (int i = 1; i <= n; i++) {
        d[i-1] = l+i-1;
    }
    int all = 0;
    rep(i,n) all += d[i];
    int ans = 0;
    int mn = 10000;
    rep(i,n) {
        int dall = all-d[i];
        if (abs(all-dall) < mn) {
            mn = abs(all-dall);
            ans = dall;
        }
    }
    cout << ans << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    if(n%k==0)
        cout<<"0"<<endl;
    else
        cout<<"1"<<endl;

    return 0;
}
