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