#include <bits/stdc++.h>
const int Inf = 1e9;
long long LINF = (long long)4e18;
const long long mod = 1e9 + 7;
using namespace std;
long long soch(long long n, long long k) {
  long long ans = 1;
  long long tmp = 1;
  for (int(i) = n - k + 1; (i) < n + 1; (i)++) ans *= (long long)i;
  for (int(i) = 2; (i) < k + 1; (i)++) tmp *= (long long)i;
  return ans / tmp;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  for (int(i) = n - k; (i) < n - 1; (i)++) {
    ans += soch(n, n - i) * (long long)pow(n - i - 1, n - i - 2);
  }
  cout << ans;
  return 0;
}
