#include <bits/stdc++.h>
using namespace std;
long long ncr(long long n, long long r) {
  long long num = 1;
  for (int i = n; i > max(r, n - r); i--) num *= i;
  long long deno = 1;
  for (int i = 1; i <= min(r, n - r); i++) deno *= i;
  return num / deno;
}
void solve() {
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  if (k == 1) ans = 1;
  if (k == 2) ans = 1 + ncr(n, 2);
  if (k == 3) ans = 1 + ncr(n, 2) + ncr(n, 3) * 2;
  if (k == 4) ans = 1 + ncr(n, 2) + ncr(n, 3) * 2 + ncr(n, 4) * 9;
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
