#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(5);
  a[0] = 1;
  a[1] = 0;
  a[2] = n * (n - 1) / 2;
  a[3] = (n * (n - 1) * (n - 2) / 6) * 2;
  a[4] = (n * (n - 1) * (n - 2) * (n - 3) / 24) * 9;
  long long ans = 0;
  for (long long i = 0; i <= k; i++) ans += a[i];
  cout << ans << '\n';
  return 0;
}
