#include<bits/stdc++.h>

using namespace std;
#define ll long long

const int N = 10000005, P = 1000000007;
int n, a, ans, fac[N], ifac[N];
int Pow(ll x, int y=P-2){
	int ans=1;
	for(; y; y>>=1, x=x*x%P) if(y&1) ans=ans*x%P;
	return ans;
}
int main() {
	scanf("%d%d", &n, &a);
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=(ll)fac[i-1]*i%P;
	ifac[n]=Pow(fac[n]);
	for(int i=n; i; --i) ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=1; i<=a; ++i) for(int j=0; j<=i; ++j)
		ans=(ans+(j&1?P-1ll:1ll)*fac[i]%P*ifac[j]%P*ifac[i-j]%P*fac[n-(i<a)-j]%P*(i-j)%P*ifac[n-a+i-j]%P*fac[n-a+i-j-1])%P;
	printf("%d\n", ans);
	return 0;
}