#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const int inf = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
const int N = (int)1e4;
const int K = 4;
long long n, k;
long long dp[N][K];
signed main() {
  scanf("%lld%lld", &n, &k);
  if (k == 1) printf("1");
  if (k == 2) printf("%lld", n * (n - 1) / 2 + 1);
  if (k == 3) printf("%lld", n * (n - 1) * (n - 2) / 3 + n * (n - 1) / 2 + 1);
  if (k == 4)
    printf("%lld", n * (n - 1) * (n - 2) * (n - 3) / 8 * 3 +
                       n * (n - 1) * (n - 2) / 3 + n * (n - 1) / 2 + 1);
  return 0;
}
