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

int M(int x) { return x >= mod ? x - mod : x; }
int n, k, res;
int fsp(long long bs, int p) {
    if (p <= 0) return 1;
    int rt = 1;
    while (p) {
        if (p & 1) rt = bs * rt % mod;
        bs = bs * bs % mod, p >>= 1;
    }
    return rt;
}

int f[2003];
int main() {
    scanf("%d%d", &n, &k);
    if (k == 1) return printf("%d\n", fsp(2, n - k - 1)), 0;
    for (int i = 1; i < n; ++i) f[i] = 1;
    for (int i = 2; i < k; ++i)
        for (int j = i; j < n; ++j) f[j] = M(f[j - 1] + f[j]);

    for (int j = k - 1; j < n; ++j) res = M(res + f[j]);
    printf("%d\n", 1ll * res * fsp(2, n - k - 1) % mod);
    return 0;
}
