#include <bits/stdc++.h>
using namespace std;
long long Det[20000];
long long C[2000];
void det() {
  Det[0] = 1;
  Det[1] = 0;
  Det[2] = 1;
  for (long long i = 3; i <= 10009; i++) {
    Det[i] = (i - 1) * (Det[i - 1] + Det[i - 2]);
  }
}
long long binomialCoeff(long long n, long long k) {
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = min(i, k); j > 0; j--) C[j] = C[j] + C[j - 1];
  }
  return C[k];
}
int main() {
  long long i, j, k, l, m, n, ans = 0;
  det();
  cin >> n >> k;
  m = n - k;
  for (i = m; i <= n; i++) {
    ans += (binomialCoeff(n, i) * Det[n - i]);
  }
  cout << ans << endl;
}
