#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005], vec;
bool vis[100005];
long long lawda_mera[100005];
void barood_bharo() {
  for (int i = 3; i < 100005; i++) {
    lawda_mera[i] = i * lawda_mera[i - 1] + (long long)pow(-1, i);
  }
}
long long kun_faya(long long a, long long b) {
  long long res = 1;
  for (int i = 0; i < b; i++) res *= (a - i);
  return res;
}
long long fact(long long n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}
int main() {
  lawda_mera[1] = 1;
  lawda_mera[2] = 1;
  barood_bharo();
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  for (int i = 2; i <= k; i++) {
    ans += (kun_faya(n, i) / fact(i)) * lawda_mera[i];
  }
  cout << ans << "\n";
}
