#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
long long comb(int n, int m) {
  long long ret = 1;
  for (int i = 1; i <= m; ++i) {
    ret *= n - i + 1;
  }
  for (int i = 1; i <= m; ++i) {
    ret /= i;
  }
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  long long ret = 0;
  if (m >= 0) {
    ++ret;
  }
  if (m >= 2) {
    ret += comb(n, 2);
  }
  if (m >= 3) {
    ret += comb(n, 3) * 2;
  }
  if (m >= 4) {
    ret += comb(n, 4) * 9;
  }
  cout << ret << endl;
  return 0;
}
