#include <bits/stdc++.h>
using namespace std;
long long f(long long x, long long y) {
  long long h = 1;
  long long g = 1;
  for (long long i = x; i > x - y; i--) h *= i;
  for (long long i = y; i >= 1; i--) g *= i;
  return h / g;
}
signed main() {
  long long n, k;
  cin >> n >> k;
  if (k == 4) {
    cout << f(n, 4) * 9 + f(n, 3) * 2 + f(n, 2) + 1;
    return 0;
  }
  if (k == 3) {
    cout << f(n, 3) * 2 + f(n, 2) + 1;
    return 0;
  }
  if (k == 2) {
    cout << f(n, 2) + 1 << endl;
    return 0;
  }
  cout << 1 << endl;
}
