#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 100;
int n, k;
long long C[maxn][maxn];
void Init() {
  C[0][0] = 1;
  for (int i = 1; i < maxn; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (j == 0 || j == i) {
        C[i][j] = 1;
      } else {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  Init();
  while (scanf("%d%d", &n, &k) != EOF) {
    long long ans = 0;
    if (k >= 1) {
      ans += 1;
    }
    if (k >= 2) {
      ans += C[n][2];
    }
    if (k >= 3) {
      ans += C[n][3] * 2;
    }
    if (k >= 4) {
      ans += C[n][4] * 9;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
