#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
long long C[N][5], dif_fact[5];
void calc() {
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j <= min(i, 4LL); j++) {
      if (j == 0 || j == i) {
        C[i][j] = 1;
      } else {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      }
    }
  }
  dif_fact[1] = 0;
  dif_fact[2] = 1;
  dif_fact[3] = 2;
  dif_fact[4] = 9;
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  calc();
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  for (long long i = 2; i <= k; i++) {
    long long curr = C[n][i] * dif_fact[i];
    ans += curr;
  }
  cout << ans;
}
