#include <bits/stdc++.h>
using namespace std;
long long N, K;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> K;
  long long ans = 0;
  ans++;
  ans += N * (N - 1) / 2;
  if (K == 1) {
    cout << "1" << endl;
    return 0;
  }
  if (K == 2) {
    cout << ans << endl;
    return 0;
  }
  ans += N * (N - 1) * (N - 2) / 3;
  if (K == 3) {
    cout << ans << endl;
    return 0;
  }
  ans += N * (N - 1) * (N - 2) * (N - 3) * 9 / 24;
  if (K == 4) {
    cout << ans << endl;
    return 0;
  }
  return 0;
}
