#include <bits/stdc++.h>
using namespace std;
long long f[10], c[1005][1005];
int main() {
  f[0] = 1;
  f[1] = 0;
  f[2] = 1;
  f[3] = 2;
  f[4] = 9;
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
  }
  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += c[n][i] * f[i];
  }
  cout << ans << endl;
  return 0;
}
