#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 1000;
int n, mxdiff;
void run() {
  scanf("%d%d", &n, &mxdiff);
  long long ret = 0;
  for (int ndiff = (0); ndiff <= (mxdiff); ++ndiff) {
    if (ndiff == 0) ret += 1;
    if (ndiff == 2) ret += (long long)n * (n - 1) / 2;
    if (ndiff == 3) ret += ((long long)n * (n - 1) * (n - 2) / 6) * 2;
    if (ndiff == 4)
      ret += ((long long)n * (n - 1) * (n - 2) * (n - 3) / 24) * (3 + 6);
  }
  printf("%lld\n", ret);
}
int main() {
  run();
  return 0;
}
