#include<cstdio>
#define ll long long
const int N=2005,mo=1e9+7;
int n,k,i,j,f[N][N][2];
void add(int &x,int k){x=(x+k)%mo;}
int main(){
	scanf("%d%d",&n,&k);f[n+1][0][0]=1;
	for (i=n+1;i>=2;i--){
		for (j=n+1-i;j>=0;j--){
			add(f[i][j][0],f[i][j+1][0]);
			for (int x=0;x<2;x++)
				add(f[i-1][j+1][1],f[i][j][x]),
				add(f[i-1][j][0],f[i][j][x]);
		}
	}
	int ans=f[1][n-k][0];
	for (i=n-k-1;i>=1;i--) ans=2ll*ans%mo;
	printf("%d",ans);
}