#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 2009;
const int MOD = 1000000007;
int f[maxn][maxn];
int N, K, ans;

int main(){
	scanf("%d%d", &N, &K);
	f[0][N+1] = 1;
	for (int i=1; i<=K; i++){
		f[i][N-i+1] = (f[i-1][N-i+2] + f[i-1][N-i+1]) % MOD;
		for (int j=N-i; j>=1; j--)
			f[i][j] = (f[i-1][j] + f[i][j+1]) % MOD;
	}
	ans = (f[K][1] - f[K-1][1] + MOD) % MOD;
	for (int i=1; i<=N-K-1; i++) ans = ans*2 % MOD;
	printf("%d\n", ans);
	return 0;
}