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