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