#include <bits/stdc++.h>
using namespace std;
long long int derange[1001];
long long int nCr(long long int n, long long int r) {
  long double ans = 1;
  long double upto = min(n - r, r);
  for (long double j = n, i = 1; j > upto; j--, i++) ans *= (j / i);
  return round(ans);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  derange[1] = 0;
  derange[2] = 1;
  for (int j = 3; j < 1001; j++)
    derange[j] = (j - 1) * (derange[j - 1] + derange[j - 2]);
  int n, k;
  cin >> n >> k;
  long long int ans = 1;
  for (int j = 2; j <= k; j++) ans += nCr(n, j) * derange[j];
  cout << ans << endl;
  return 0;
}
