#include <bits/stdc++.h>
using namespace std;
long long derangements(long long n) {
  if (n == 0) return 1;
  if (n == 1) return 0;
  if (n == 2) return 1;
  return (n - 1) * (derangements(n - 1) + derangements(n - 2));
}
long long nCr(long long n, long long r) {
  long long res = 1;
  if (r == 0) return res;
  for (long long i = 0; i < r; i++) res *= (n - i);
  for (long long i = 2; i <= r; i++) res /= i;
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k, ans = 0;
  cin >> n >> k;
  for (long long i = 0; i <= k; i++) ans += (nCr(n, i) * derangements(i));
  cout << ans;
  return 0;
}
