#include <bits/stdc++.h>
using namespace std;
long long a[10];
int main() {
  int n, k;
  while (scanf("%d %d", &n, &k) != EOF) {
    long long ans = 0;
    a[4] = 1ll * n * (n - 1) * (n - 2) * (n - 3) / 24 * 9;
    a[3] = 1ll * n * (n - 1) * (n - 2) / 6 * 2;
    a[2] = 1ll * n * (n - 1) / 2;
    a[1] = 0;
    a[0] = 1;
    for (int i = 0; i <= k; i++) ans += a[i];
    printf("%lld\n", ans);
  }
  return 0;
}
