#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cout.tie(nullptr);
  std::cin.tie(nullptr);
  std::cerr.tie(nullptr);
  int64_t n, k;
  std::cin >> n >> k;
  if (k == 1) std::cout << "1\n";
  if (k == 2) {
    int64_t res = (n * (n - 1)) / 2 + 1;
    std::cout << res << '\n';
  }
  if (k == 3) {
    int64_t res = (n * (n - 1) * (n - 2)) / 3 + (n * (n - 1)) / 2 + 1;
    std::cout << res << '\n';
  }
  if (k == 4) {
    int64_t res = (n * (n - 1) * (n - 2)) / 3 + (n * (n - 1)) / 2 +
                  9 * (n * (n - 1) * (n - 2) * (n - 3)) / 24 + 1;
    std::cout << res << '\n';
  }
}
