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

typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= MOD;
	if(k%2 == 1){
		ret *= x;
		ret %= MOD;
	}
	return ret;
}

int main(){
	ll n,k;
	cin >> n >> k;
	
	ll dp[2][2002] = {};
	ll t = 0, t_ = 1;
	dp[t][1] = 1;
	for(int i = k-1 ; i >= 1 ; i --){
		for(int j = 1 ; j <= n-i ; j ++){
			dp[t_][j] = dp[t_][j-1]+dp[t][j];
			if(dp[t_][j] >= MOD)dp[t_][j] -= MOD;
		}
		swap(t,t_);
	}
	ll ret = 0;
	for(int i = 0 ; i < 2002 ; i ++){
		ret += dp[t][i];
	}
	ret %= MOD;
	if(k < n){
		ret *= modpow(2,n-k-1);
		ret %= MOD;
	}
	cout << ret << endl;
}
