#include <bits/stdc++.h>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define drep(i,x,y) for(int i=(x);i>=(y);i--)
using namespace std;
const int sz=2007;
const int mod=1e9+7;
int f[sz][sz],sum[sz][sz];
int qpow(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) ret=1ll*x*ret%mod;
	return ret;
}
int main(){
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	rep(i,2,n+1) sum[0][i]=1;
	rep(i,1,k-1) drep(j,n-i+1,2){
		if(j<=n-i+1) (f[i][j]+=sum[i-1][j])%=mod;
		sum[i][j]=(sum[i][j+1]+f[i][j])%mod;
	}
	rep(i,2,n-k+2) (ans+=1ll*f[k-1][i])%=mod;
	if(k==1) ans=1;
	if(k!=n) ans=1ll*ans*qpow(2,n-k-1)%mod;
	printf("%d\n",ans); 
}