#include <bits/stdc++.h>
using namespace std;
int n, k;
int used[1005], res[10];
long long ans, c[1005][10];
long long hes(int x, int y) {
  long long res = 1;
  int j = 1;
  for (int i = x; i + y > x; i--) {
    res *= i;
    res /= j;
    j++;
  }
  return res;
}
void comb() {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      c[i][j] = hes(i, j);
    }
  }
}
void dfs(int now, int siz) {
  if (now > siz) {
    res[siz]++;
    return;
  }
  for (int i = 1; i <= siz; i++) {
    if (i == now) continue;
    if (!used[i]) {
      used[i] = 1;
      dfs(now + 1, siz);
      used[i] = 0;
    }
  }
}
void check(int siz) { dfs(1, siz); }
int main() {
  scanf("%d %d", &n, &k);
  res[0] = 1;
  for (int i = 1; i <= 4; i++) {
    check(i);
  }
  comb();
  for (int i = 0; i <= k; i++) {
    ans = ans + c[n][i] * res[i];
  }
  printf("%lld", ans);
}
