#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int n,K,i,j,k,ans,f[2005][2005][2];
int main()
{
	scanf("%d %d",&n,&K);
	f[n+1][0][0]=1;
	fd(i,n+1,2)
	{
		fd(j,n,0) (f[i][j][0]+=f[i][j+1][0])%=mo;
		fo(j,0,n)
			fo(k,0,1)
			{
				(f[i-1][j+1][1]+=f[i][j][k])%=mo;
				(f[i-1][j][0]+=f[i][j][k])%=mo;
			}
	}
	ans=f[1][n-K][0];
	fo(i,1,n-K-1) 
		ans=ans*2%mo;
	printf("%d",ans);
}