#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<int> pqi1;
typedef priority_queue<int, vector<int>, greater<int>> pqi2;
long long derange[1001];
long long fact(long long n) {
  long long ans = 1;
  for (long long i = 2; i <= n; i++) {
    ans *= i;
  }
  return ans;
}
long long choose(long long n, long long r) {
  long long a = 1;
  for (long long i = r - 1; i > -1; i--) {
    a *= (n - i);
  }
  a /= fact(r);
  return a;
}
int main() {
  derange[0] = 0;
  derange[1] = 0;
  derange[2] = 1;
  for (int i = 3; i < 1001; i++) {
    derange[i] = (i - 1) * (derange[i - 1] + derange[i - 2]);
  }
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i < k + 1; i++) {
    ans += derange[i] * choose(n, i);
  }
  cout << ans + 1 << endl;
}
