#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcnt(s);
}
unsigned long long fac(int k) {
  unsigned long long ans = 1;
  for (int i = 2; i <= k; i++) {
    ans *= i;
  }
  return ans;
}
unsigned long long nCk(int n, int k) {
  unsigned long long res = 1;
  if (k > n - k) {
    k = n - k;
  }
  for (int i = 0; i < k; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  unsigned long long ans = 1;
  unsigned long long sum_0 = 1;
  unsigned long long sum_1 = 0;
  for (int i = 2; i <= k; i++) {
    unsigned long long t = (i - 1) * (sum_0 + sum_1);
    sum_0 = sum_1;
    sum_1 = t;
    ans += t * nCk(n, i);
  }
  cout << ans << endl;
  return 0;
}
