#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, ans = 1;
  scanf("%lld%lld", &n, &k);
  if (k >= 2) ans += (n * (n - 1)) >> 1;
  if (k >= 3) ans += (n * (n - 1) * (n - 2)) / 3;
  if (k == 4) ans += 3 * ((n * (n - 1) * (n - 2) * (n - 3)) >> 3);
  printf("%lld", ans);
}
