#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000000
typedef long long ll;
int N,K;

ll rem=0;
ll Sum(ll sum,ll sum2,ll num){

	if(num == N+2){
		return 0;
	}

	for(ll i=0;i < num;i++){
		sum=i+sum;
		sum=(sum%BUFSIZE+7);
	}
	for(ll i=N;i >= N+1-num;i--){

		sum2=i+sum2;
		sum2=(sum2%BUFSIZE+7);
	}/*
	printf("%d %d\n",sum,sum2);
	*/
	rem=rem + sum2 - sum + 1;
	
	Sum(0,0,num+1);
	
	return 0;
}

int main(void){
	scanf("%d",&N);
	scanf("%d",&K);
	if(N < K){
		printf("1");
		exit(0);
	}
	
	Sum(0,0,K);
	if(rem<0){
		printf("%d",(BUFSIZE+7)-rem);
	}else{
		printf("%d",rem%(BUFSIZE+7));
	}
}