#include <bits/stdc++.h>
using namespace std;
const long long MAX5 = 1e+5 + 7;
const long long MAX7 = 1e+7 + 7;
const long long MAXN = MAX7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const long long MOD = 1e9 + 7;
long long T = 1;
long long n, x, k, p, m, y;
string second, t;
long double w;
vector<long long> de;
long long NCR(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  if (r > n / 2) return NCR(n, n - r);
  long long res = 1;
  for (long long k = 1; k <= r; ++k) {
    res *= n - k + 1;
    res /= k;
  }
  return res;
}
void deg() {
  de[0] = 1;
  de[1] = 0;
  de[2] = 1;
  for (long long i = 3; i <= k; i++) {
    de[i] = (i - 1) * (de[i - 1] + de[i - 2]);
  }
}
void MAIN() {
  cin >> n >> k;
  de = vector<long long>(k + 1);
  deg();
  long long ans = 0;
  for (long long i = 0; i <= k; i++) {
    ans += de[i] * NCR(n, i);
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(12);
  ;
  mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  ;
  while (T--) {
    MAIN();
  }
  return 0;
}
