#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void) {

ll N , K;
scanf("%lld %lld",&N,&K);

if (K>N)
{
    printf("%lld",K-N);
    return 0;
}

ll sum = (N*N)%(1000000007);
printf("%lld",sum+1);

 return EXIT_SUCCESS;
}

