#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const long long mod = (long long)1e9 + 7;
long long dp[maxn][maxn][2][2], n, k;
long long c[maxn][maxn], ans[maxn], fac[maxn];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    c[i][0] = c[i][i] = 1LL;
    for (int j = 1; j <= i - 1; j++) {
      c[i][j] = (c[i][j] + c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  fac[0] = fac[1] = 1LL;
  for (int i = 2; i <= 2001; i++) {
    fac[i] = (fac[i - 1] * i * 1LL) % mod;
  }
  dp[0][0][1][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i - 1; j++) {
      for (int now = 0; now < 2; now++) {
        for (int ne = 0; ne < 2; ne++) {
          dp[i][j][ne][0] = (dp[i][j][ne][0] + dp[i - 1][j][now][ne]) % mod;
          if (!now) {
            dp[i][j + 1][ne][0] =
                (dp[i][j + 1][ne][0] + dp[i - 1][j][now][ne]) % mod;
          }
          if (i < n) {
            dp[i][j + 1][ne][1] =
                (dp[i][j + 1][ne][1] + dp[i - 1][j][now][ne]) % mod;
          }
        }
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int now = 0; now < 2; now++) {
      for (int ne = 0; ne < 2; ne++) {
        ans[i] = (ans[i] + dp[n][i][now][ne]) % mod;
      }
    }
    ans[i] = ans[i] * fac[n - i] % mod;
  }
  int flag = -1;
  for (int i = k + 1; i <= n; i++) {
    ans[k] = (ans[k] + flag * c[i][k] * ans[i] + mod) % mod;
    flag *= -1;
  }
  printf("%lld\n", ans[k]);
}
