#include <bits/stdc++.h>
using namespace std;
const long long N = 31;
long long timer, cc, cc1;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long ncr[1005][5];
void compute() {
  long long i, j;
  for (i = 0; i < 1005; i++) {
    for (j = 0; j < 5; j++) {
      if (j == 0 || i == j) {
        ncr[i][j] = 1;
      } else if (j > i) {
        ncr[i][j] = 0;
      } else
        ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j];
    }
  }
}
int main() {
  boost();
  compute();
  long long i, t, n, q, l, r, ans, mid, c = 0, j, k, z, tc;
  long long h, m, u, mm, w, mx, x, y, l1, r1, d = 0, mask;
  long double f, f1;
  long long a[5];
  a[0] = 0;
  a[1] = 0;
  a[2] = 1;
  for (i = 3; i < 5; i++) {
    a[i] = (i - 1) * (a[i - 1] + a[i - 2]);
  }
  cin >> n >> k;
  ans = 1;
  for (i = 0; i <= k; i++) {
    z = ncr[n][i] * a[i];
    ans += z;
  }
  cout << ans << '\n';
  return 0;
}
