#include <bits/stdc++.h>
using namespace std;
long long int dp[(int)(1e3 + 5)], n, k, ans = 1,
                                        com[(int)(1e3 + 5)][(int)(1e3 + 5)];
long long int dfs(int n) {
  if (n == 1) return 0;
  if (n == 2) return 1;
  if (~dp[n]) return dp[n];
  return dp[n] = ((n - 1) * (dfs(n - 1) + dfs(n - 2)) % (1000000007)) %
                 (1000000007);
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%lld %lld", &n, &k);
  com[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    com[i][0] = 1;
    for (int j = 1; j <= i; j++) com[i][j] = com[i - 1][j] + com[i - 1][j - 1];
  }
  for (int i = k; i > 1; i--) ans += dfs(i) * com[n][i];
  printf("%lld\n", ans);
}
