#include <bits/stdc++.h>
using namespace std;
const int MXN = 2e6 + 30;
const int MAXN = 1e3 + 2;
const long long INF = 1e9 + 7;
const long long BINF = 1e15;
const int MOD = 1e9 + 7;
const long double EPS = 1e-15;
const long long dx[] = {0, 0, 1, -1};
const long long dy[] = {1, -1, 0, 0};
long long n, k;
long long cnt = 1;
long long ans[MXN];
vector<long long> v;
long long cnk(long long n, long long k) {
  if (k == 2) {
    return n * (n - 1) / k;
  }
  if (k == 3) {
    return n * (n - 1) * (n - 2) / 6LL;
  }
  if (k == 4) {
    return n * (n - 1) * (n - 2) * (n - 3) / 24LL;
  }
}
int main() {
  cin >> n >> k;
  ans[2] = 1;
  ans[4] = 9;
  for (int i = 3; i <= 3; i++) {
    v.clear();
    for (int j = 1; j <= i; j++) {
      v.push_back(j);
    }
    while (next_permutation(v.begin(), v.end())) {
      int q = 1;
      for (int j = 1; j <= i; j++) {
        if (v[j] == j) q = 0;
      }
      if (q) ans[i]++;
    }
  }
  for (int i = 2; i <= k; i++) {
    cnt += cnk(n, i) * 1LL * ans[i];
  }
  cout << cnt;
  return 0;
}
