#include<bits/stdc++.h>
using namespace std;

const int mo=1e9+7;
int n,k,dp[2010][2010][2];

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&k);
	dp[n][0][0]=1;
	for (i=n;i>=1;i--)
	{
		for (j=n;j>=0;j--)
			(dp[i][j][1]+=dp[i][j+1][1])%=mo;
		for (j=0;j<=n;j++)
		{
			(dp[i-1][j+1][0]+=dp[i][j][0])%=mo;
			(dp[i-1][j+1][0]+=dp[i][j][1])%=mo;
			(dp[i-1][j][1]+=dp[i][j][0])%=mo;
			(dp[i-1][j][1]+=dp[i][j][1])%=mo;
		}
	}
	int Ans=(dp[1][n-k][0]+dp[1][n-k][1])%mo;
	for (i=1;i<n-k;i++) Ans=(Ans+Ans)%mo;
	printf("%d\n",Ans);
}
