#include<bits/stdc++.h>
using namespace std;
const int N=2005,M=1e9+7;
int n,m,f[N];
int main(){
	scanf("%d%d",&n,&m);
	f[n+1]=1;
	for (int i=1;i<m;i++){
		int sum=f[n-i+2];
		for (int j=n-i+1;j>=2;j--){
			(sum+=f[j])%=M;
			if (j<=n-i+1)f[j]=sum;
		}
	}
	int ans=0;
	if (m==1)ans=1;
	else for (int j=2;j<=n-(m-1)+1;j++)(ans+=f[j])%=M;
	for (int i=1;i<=n-m-1;i++)(ans*=2)%=M;
	printf("%d\n",ans);
}
