#include <bits/stdc++.h>
using namespace std;
int bico(int n, int k) {
  if (k == n || k == 0)
    return 1;
  else
    return bico(n - 1, k - 1) + bico(n - 1, k);
}
int main() {
  long long int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << "1";
  } else if (k == 2) {
    cout << (n * (n - 1) / 2) + 1;
  } else if (k == 3) {
    cout << (n * (n - 1) * (n - 2)) / 3 + (n * (n - 1) / 2) + 1;
  } else if (k == 4) {
    cout << (n * (n - 1) * (n - 2) * (n - 3) * 3) / 8 +
                (n * (n - 1) * (n - 2)) / 3 + (n * (n - 1)) / 2 + 1;
  }
  cout << endl;
  return 0;
}
