#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  int 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) / 6 * 2 + n * (n - 1) / 2 + 1;
  else
    cout << n * (n - 1) * (n - 2) * (n - 3) / 24 * 9 +
                n * (n - 1) * (n - 2) / 6 * 2 + n * (n - 1) / 2 + 1;
  return 0;
}
