#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const long long MOD = 1e9+7;
const long long MAXN = 2e3+5;
long long dp[MAXN][MAXN];
long long suff[MAXN];
int main(){
    long long n,k;
    cin>>n>>k;
    dp[0][n] = 1;
    if(n==1 && k==1){
        cout<<1<<endl;
        return 0;
    }
    for(long long i=1;i<=k;i++){
        for(long long j=n;j>=1;j--){
            suff[j] = suff[j+1]+dp[i-1][j];
            suff[j]%=MOD;
            if(j<=(n-i+1)){
                dp[i][j] =suff[j];
                dp[i][j]%=MOD;
            }
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
        
    }
    
    long long ans = (dp[k][1] - dp[k-1][1] + MOD)%MOD;
    //cout<<ans<<endl;
    for(long long i=1;i<=n-k-1;i++){
        ans*=2;
        ans%=MOD;
    }
    cout<<ans<<endl;
}