#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
int fpow(int x, int y) { 
	if (y < 0) return 1; 
	int res = 1; 
	while (y) { 
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
const int MAX_N = 2005; 
int N, K, f[MAX_N][MAX_N], sum[MAX_N]; 
int main () { 
	cin >> N >> K; 
	f[0][N + 1] = 1; 
	for (int i = 1; i <= K; i++) {
		sum[N + 1] = f[i - 1][N + 1];
		for (int j = N; j; j--) sum[j] = (sum[j + 1] + f[i - 1][j]) % Mod;
		for (int j = 1; j <= N - i + 1; j++) f[i][j] = sum[j];
	}
	printf("%lld\n", 1ll * fpow(2, N - K - 1) * sum[2] % Mod);
	return 0; 
} 