#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<vector<ll>> choose(n + 1, vector<ll>(k + 1));
  choose[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    choose[i][0] = 1;
    if (i <= k) {
      choose[i][i] = 1;
    }
    for (int j = 1; j < min(i, k + 1); j++) {
      choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
    }
  }
  vector<int> der{1, 0, 1, 2, 9};
  ll ans = 0;
  for (int i = n - k; i <= n; i++) {
    ans += choose[n][n - i] * der[n - i];
  }
  cout << ans << "\n";
}
