#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
const int MOD = 1000000007;
const int INF = 1e8;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
long long des[MAX];
long long solve(long long n, long long k) {
  if (k == 1) {
    return 1;
  }
  long long res = 1;
  for (long long i = n - k + 1; i <= n; i++) {
    res *= i;
  }
  for (long long i = 2; i <= k; i++) {
    res /= i;
  }
  res *= des[k];
  res += solve(n, k - 1);
  return res;
}
int main() {
  long long n, k;
  cin >> n >> k;
  des[0] = 1;
  des[1] = 1;
  for (long long i = 1; i < MAX; i++) {
    des[i] = (i - 1) * (des[i - 1] + des[i - 2]);
  }
  cout << solve(n, k) << '\n';
  return 0;
}
