#include <bits/stdc++.h>
using namespace std;
vector<long long> der(int k) {
  vector<long long> res;
  res.push_back(0);
  res.push_back(1);
  for (long long i = 3; i <= k; i++) {
    int n1 = res[i - 2];
    int n2 = res[i - 3];
    int cur = (i - 1) * (n1 + n2);
    res.push_back(cur);
  }
  return res;
}
long long nck(int n, int k) {
  long long denom = 1, nume = 1;
  for (long long i = n - k + 1; i <= n; i++) {
    nume *= i;
  }
  for (long long i = 1; i <= k; i++) denom *= i;
  return nume / denom;
}
void solve() {
  int n, k;
  cin >> n >> k;
  long long res = 1;
  vector<long long> d = der(k + 1);
  for (int i = k; i >= 1; i--) {
    long long a = nck(n, i);
    long long b = d[i - 1];
    res += (a * b);
  }
  cout << res << endl;
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
