#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,sum[2005],dp[2005][2005],mod=1e9+7,ans;
long long qp(long long x,long long y)
{
	if (y==0) return 1;
	if (y==1) return x;
	long long z=qp(x,y/2);
	z=z*z%mod;
	if (y&1) z=z*x%mod;
	return z;
}
int main()
{
	cin>>n>>m;
	if (n==1)
	{
		cout<<1;
		return 0;
	}
	if (m==1)
	{
		cout<<qp(2,n-2);
		return 0;
	}
	dp[0][n+1]=1;
	for (i=1;i<m;i++)
	{
		sum[n+1]=dp[i-1][n+1];
		for (j=n+1;j>=1;j--)
		{
			sum[j]=sum[j+1]+dp[i-1][j];
			sum[j]%=mod;
		}
		for (j=1;j<=n;j++)
		{
			if (i+j-1<=n) dp[i][j]=sum[j];
		}
	}
	for (i=2;i<=n;i++)
	{
		ans=(ans+dp[m-1][i])%mod;
	}
	if (n==m)
	{
		cout<<ans;
		return 0;
	}
	cout<<ans*qp(2,n-m-1)%mod;
	return 0;
}