#include <bits/stdc++.h>
using namespace std;
inline long long int c(long long int n, long long int i) {
  if (i == 0)
    return 1;
  else if (i == 1)
    return n;
  else if (i == 2)
    return (n * (n - 1)) / 2;
  else if (i == 3)
    return (n * (n - 1) * (n - 2)) / 6;
  else if (i == 4)
    return (n * (n - 1) * (n - 2) * (n - 3)) / 24;
}
int main() {
  long long int d[5];
  d[0] = 1;
  d[1] = 0;
  d[2] = 1;
  d[3] = 2;
  d[4] = 9;
  long long int n, k;
  cin >> n >> k;
  long long int ans = 0;
  for (long long int i = 0; i <= k; i++) ans += d[i] * c(n, i);
  cout << ans;
  return 0;
}
