#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 5;
long long int Table[MAX][MAX];
int Dearrangement(int n) {
  if (n == 0) return 1;
  if (n == 1) return 0;
  if (n == 2) return 1;
  int ans = (n)*Dearrangement(n - 1) + ((n % 2) ? -1 : 1);
  return ans;
}
long long int ncr(int n, int r) {
  if (r == 0 || n == r) return Table[n][r] = 1;
  if (n < 1 || r < 1) return 0;
  if (Table[n][r] != -1) return Table[n][r];
  return Table[n][r] = ncr(n - 1, r - 1) + ncr(n - 1, r);
}
int main() {
  memset(Table, -1, sizeof Table);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i <= n; i++) Table[n][i] = ncr(n, i);
  long long int ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += Table[n][n - i] * 1LL * Dearrangement(i);
  }
  cout << ans;
  return 0;
}
