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