#include <bits/stdc++.h>
using namespace std;
long long ncr(int n, int r) {
  if (n == r) return 1;
  r = min(n - r, r);
  long long ans = 1ll;
  for (int i = 0; i < r; i++) {
    ans = ans * (n - i) / (i + 1);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  long long ans = 1ll;
  int x = n - k;
  vector<long long> dp(k + 1, 0);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 1;
  vector<long long> fact(k + 1, 0);
  fact[2] = 2ll;
  for (int i = 3; i <= k; i++) {
    fact[i] = i * fact[i - 1];
    dp[i] = fact[i] - 1;
    for (int j = 1; j <= (i - 2); j++) {
      dp[i] -= ncr(i, j) * dp[i - j];
    }
  }
  for (int i = x; i <= n; i++) {
    long long nci = ncr(n, i);
    ans += nci * dp[n - i];
  }
  cout << ans;
  return 0;
}
