#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int sum = 0;
  long long int n, k;
  cin >> n >> k;
  switch (k) {
    case 4: {
      long long int t;
      t = n * (n - 1) * (n - 2) * (n - 3) / 24 * 9;
      sum += t;
    }
    case 3: {
      long long int t;
      t = n * (n - 1) * (n - 2) / 6 * 2;
      sum += t;
    }
    case 2: {
      long long int t;
      t = n * (n - 1) / 2 * 1;
      sum += t;
    }
    case 1:
      sum += 1;
  }
  cout << sum << endl;
  return 0;
}
