#include<bits/stdc++.h>

using namespace std;

int N, K, mod = 1e9 + 7, c[2017][2017];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void PrintSet (set < vector < int > > S)
{
    for (auto it = S.begin (); it != S.end (); it ++, printf ("\n"))
        for (auto it2 = (*it).begin (); it2 != (*it).end (); it2 ++)
            printf ("%d ", *it2);
}

void Brute2 ()
{
    int p[20];
    set < vector < int > > S;
    for (int i=1; i<=N; i++)
        p[i] = i + 1;
    do {
        bool ok = 1;
        for (int i=1; i<=N; i++)
            for (int j=i + 1; j<=N; j++)
                if (p[i] < p[j])
                    for (int k=j + 1; k<=N; k++)
                        if (p[j] < p[k])
                        {
                            ok = 0;
                            i = j = N + 2;
                            break;
                        }
        if (ok)
        {
            vector < int > curr;
            for (int i=1; i<=N; i++)
                curr.push_back (p[i]);
            S.insert (curr);
        }
    }while (next_permutation (p + 1, p + N + 1));
    //PrintSet (S);
    printf ("%d\n", S.size ());
}

int cnt[20];
void Brute (int N, int K)
{
    set < vector < int > > S;
    for (int i=0; i<(1 << (N - 1)); i++)
        for (int j=0; j<(1 << (N - 1)); j++)
        {
            deque < int > dq;
            dq.push_back (1);
            for (int k=0; k<(N - 1); k++)
                if (i & (1 << k)) dq.push_back (k + 2);
                else dq.push_front (k + 2);
            vector < int > curr;
            for (int k=0; k<N - 1; k++)
                if (j & (1 << k)) curr.push_back (dq.front ()), dq.pop_front ();
                else curr.push_back (dq.back ()), dq.pop_back ();
            curr.push_back (dq.back ());
            S.insert (curr);
        }
    for (auto it = S.begin (); it != S.end (); it ++)
        if ((K != 0 &&(*it) [K - 1] == 1) || K == 0)
        {
            int pos = 0;
            for (auto it2 = (*it).begin (); it2 != (*it).end (); it2 ++)
            {
                pos ++;
                if ((*it2) == 1) cnt[pos] ++;
                printf ("%d ", *it2);
            }
            printf ("\n");
        }
    printf ("\n%d = \n", S.size ());
    for (int i=1; i<=N; i++)
        printf ("%d ", cnt[i]);
    printf ("\n");
}

int dp0[] = {1, 1,2,5,14,42,132,429};
int dp[2017][2017], fac[2017], put2[2017];

void doDp (int N)
{
    dp[N][0] = 1;
    for (int i=N; i>=1; i--)
        for (int j=N - i + 1; j>=0; j--)
            dp[i][j] = add (dp[i][j], dp[i][j + 1]),
            dp[i - 1][j + 1] = add (dp[i - 1][j + 1], dp[i][j]);
}

int solve (int N, int K)
{
    int ans = mul (dp[1][N - K], put2[max (N - K - 1, 0)]);
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K);
//Brute2 ();
//Brute (8, 0);
c[0][0] = 1, fac[0] = 1, put2[0] = 1;
for (int i=1; i<=N; i++)
{
    c[i][0] = 1, fac[i] = mul (fac[i - 1], i), put2[i] = add (put2[i - 1], put2[i - 1]);
    for (int j=1; j<=i; j++)
        c[i][j] = add (c[i - 1][j - 1], c[i - 1][j]);
}
doDp (N);
printf ("%d\n", solve (N, K));
/*for (int i=1; i<=N; i++)
    printf ("%d ", solve (N, i));
printf ("\n");*/
return 0;
}


Measured memory_bytes: 27904