#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long cmb(long long n, long long k) {
  double res = 1;
  for (long long i = 0; i < k; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return (long long)(res + 0.1);
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  long long answ = 1;
  for (long long i = 2; i <= k; i++) {
    long long temp = cmb(n, n - i);
    if (i == 3) temp *= 2;
    if (i == 4) temp *= 9;
    answ += temp;
  }
  cout << answ;
}
