#include <bits/stdc++.h>
using namespace std;
long long unorder(int n) {
  if (n == 0) return 1;
  if (n == 1) return 0;
  bool good;
  long long ans = 0;
  vector<int> V(n);
  for (int i = 0; i < n; i++) V[i] = i;
  do {
    good = true;
    for (int i = 0; i < n && good; i++) good = (V[i] != i);
    if (good) ans++;
  } while (next_permutation(V.begin(), V.end()));
  return ans;
}
long long newton(int n, int k) {
  if (k > n) return 0;
  if (2 * k > n) k = n - k;
  long long ans = 1;
  for (int i = n - k + 1; i <= n; i++) ans *= i;
  for (int i = 1; i <= k; i++) ans /= i;
  return ans;
}
int main() {
  int n, k;
  long long ans = 0;
  cin >> n >> k;
  for (int i = 0; i <= k; i++) {
    long long unorders = unorder(i), combinations = newton(n, n - i);
    ans += combinations * unorders;
  }
  cout << ans << endl;
  return 0;
}
