#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, a[4];
  cin >> n >> k;
  a[0] = 1;
  a[1] = n * (n - 1) / 2;
  a[2] = n * (n - 1) * (n - 2) / 6 * 2;
  a[3] = n * (n - 1) * (n - 2) * (n - 3) / 24 * (3 + 6);
  long long ans = 0;
  for (int i = 0; i < k; i++) ans += a[i];
  cout << ans << endl;
  return 0;
}
