#include<cstdio>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
using namespace std;
typedef long long ll;
const int maxn=4010;
const int mod=1000000007;
int n,k,fac[maxn],ifac[maxn];
int C(int a,int b) {return (ll)fac[a]*ifac[b]%mod*ifac[a-b]%mod;}
int main() {
	scanf("%d%d",&n,&k);
	ifac[1]=ifac[0]=fac[0]=1;
	rep(i,2,n+k) ifac[i]=(ll)(mod-mod/i)*ifac[mod%i]%mod;
	rep(i,1,n+k) fac[i]=(ll)fac[i-1]*i%mod,ifac[i]=(ll)ifac[i-1]*ifac[i]%mod;
	int ans=(C(n-1+k-1,k-1)-(k>=2?C(n+k-2,k-2):0)+mod)%mod;
	rep(i,1,n-k-1) ans=(ans+ans)%mod;
	printf("%d\n",ans);
	return 0;
}
