#include <iostream>
#include <bits/stdc++.h>
#define m 1000000007
using namespace std;
typedef long long ll;
typedef long l;
ll Chinese_Remainder_Theorem();
ll ans=0;
ll power(ll a,ll b);
ll gcd(ll a,ll b,ll &x, ll &y);
ll fib(ll n);
bool is_prime(ll n);
vector <ll> prime_factors(ll n);
vector <ll> sieve(ll n);
ll euler_totient(ll n);
void Matrix_Power(ll A[2][2], ll n);
void multiply(ll A[2][2], ll B[2][2]);
int main()
{
    ios_base::sync_with_stdio(false);

    ll n,k;
    cin>>n>>k;
    n++;
    if(k>=n)
    {
        cout<<"1\n";
        return 0;
    }
    vector <ll> v1(n);
    vector <ll> v2(n);
    for(int i=0;i<v1.size();i++)
    {
        v1[i]=(i+1);
        v2[i]=(i+1);
    }
    reverse(v2.begin(),v2.end());
    ll total=1;
    ll ptr=k-1;
    ll sum1=0;
    ll sum2=0;
    /*for(int i=0;i<v1.size();i++)
    {
        cout<<v1[i]<<" ";
    }
    cout<<"\n";
      for(int i=0;i<v1.size();i++)
    {
        cout<<v2[i]<<" ";
    }
    cout<<"\n";
    */
    for(int i=0;i<=ptr;i++)
    {
        sum1+=v1[i];
        sum2+=v2[i];
    }
    //cout<<sum1<<" "<<sum2<<"\n";
    total=(total+1+abs(sum2-sum1))%m;
    for(int i=ptr+1;i<v1.size();i++)
    {
        if(i==v1.size()-1) break;
        sum1+=v1[i];
        sum2+=v2[i];
        //cout<<sum1<<" "<<sum2<<"\n";
        total=(total+1+abs(sum2-sum1))%m;
    }
    cout<<total<<"\n";

    return 0;
}
ll power(ll a, ll b)
{
    if(b==0) return 1;
    ll half=power(a,b/2);
    ll ret=(half*half)%m;
    if(b%2==1) ret=(ret*a)%m;
    return ret;
}
ll gcd(ll a, ll b, ll &x, ll &y)
{
    if(a==0)
    {
        x=0;
        y=1;
        return b;
    }
    ll x1,y1;
    ll d=gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    ans=(x+b)%b;
    return d;
}
ll fib(ll n)
{
    if(n==0) return 0;
    ll  A[2][2]={{1,1},{1,0}};
    Matrix_Power(A,n-1);
    return A[0][0];
}
void Matrix_Power(ll A[2][2], ll n)
{
    if(n==0||n==1)
    {
        return;
    }
    Matrix_Power(A,n/2);
    multiply(A,A);
    if(n%2==1) { ll B[2][2]={{1,1},{1,0}}; multiply(A,B); }

}
void multiply(ll A[2][2], ll B[2][2])
{
    ll x,y,z,w;
    x=(A[0][0]*B[0][0])+(A[0][1]*B[1][0]);
    y=(A[0][0]*B[0][1])+(A[0][1]*B[1][1]);
    z=(A[1][0]*B[0][0])+(A[1][1]*B[1][0]);
    w=(A[1][0]*B[0][1])+(A[1][1]*B[1][1]);
    A[0][0]=x;
    A[0][1]=y;
    A[1][0]=z;
    A[1][1]=w;
}
bool is_prime(ll n)
{
    for(l i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
vector <ll> prime_factors(ll n)
{
    vector <ll> v1;
    while(n%2==0)
    {
        v1.push_back(2);
        n/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2)
    {
        if(n==1) break;
        while(n%i==0)
        {
            v1.push_back(i);
            n/=i;
        }
    }
    if(n>1) v1.push_back(n);
    return v1;
}
vector <ll> sieve(ll n)
{
    vector <ll> v1(n+1);
    ll i,j;
    v1[0]=v1[1]=0;
    for(i=2;i<=n;i++)
    {
        v1[i]=i;
    }
    for(i=2;i<=n;i++)
    {
        if(v1[i]==0) continue;
        for(j=i+i;j<=n;j+=i)
        {
            v1[j]=0;
        }
    }
    vector <ll> v2;
    for(i=1;i<=n;i++)
    {
        if(v1[i]!=0)
        {
            v2.push_back(i);
        }
    }
    return v2;
}
ll euler_totient(ll n)
{
    if(n==1) return 1;
    vector <ll> v1=prime_factors(n);
    ll i;
    vector <ll> v2;
    v2.push_back(v1[0]);
    for(i=1;i<v1.size();i++)
    {
        if(v1[i]==v1[i-1]) continue;
        v2.push_back(v1[i]);
    }
    ll store=n;
    for(i=0;i<v2.size();i++)
    {
        store*=(v2[i]-1);
    }
    for(i=0;i<v2.size();i++)
    {
        store/=v2[i];
    }
    return store;
}
ll Chinese_Remainder_Theorem()
{
    cout<<"ENTER THE NUMBER OF EQUATIONS\n";
    ll n,i,num1,num2;
    cin>>n;
    pair <ll,ll> p1[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>num1>>num2;
        p1[i]=make_pair(num1,num2);
    }
    vector <ll> v1(n+1);
    ll M=1;
    for(i=1;i<=n;i++) { M*=p1[i].second;      }
    for(i=1;i<=n;i++) { v1[i]=M/p1[i].second; }
    ll X,sum=0;
    ll a,b,x,y;
    for(i=1;i<=n;i++)
    {
        a=v1[i];
        b=p1[i].second;
        gcd(a,b,x,y);
        x=p1[i].first*v1[i]*ans;
        sum+=x%M;
    }
    return sum%M;
}


Measured memory_bytes: 6428