#include <bits/stdc++.h>
using namespace std;
long long ncr(long long n, long long l) {
  long long r = n - l;
  if (l > r) swap(l, r);
  long long up = 1;
  for (long long i = r + 1; i <= n; i++) {
    up = up * i;
  }
  long long down = 1;
  for (long long i = 2; i <= l; i++) {
    down = down * i;
  }
  long long res = up / down;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long a[5];
  a[2] = 1, a[3] = 2, a[4] = 9;
  long long ans = 1;
  for (long long take = 2; take <= k; take++) {
    long long res = ncr(n, take);
    res = (res * a[take]);
    ans += res;
  }
  cout << ans << "\n";
  return 0;
}
