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