#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const int N = 1e3 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
long long n, k;
long long d[] = {1, 0, 1, 2, 9};
long long binom[N][N];
long long ans;
int main() {
  scanf("%lld %lld", &n, &k);
  ans += d[0];
  if (k >= 1) ans += d[1] * n;
  if (k >= 2) ans += d[2] * (n * (n - 1)) / 2;
  if (k >= 3) ans += d[3] * (n * (n - 1) * (n - 2)) / 6;
  if (k >= 4) ans += d[4] * (n * (n - 1) * (n - 2) * (n - 3)) / 24;
  printf("%lld\n", ans);
  return 0;
}
