#include <bits/stdc++.h>
using namespace std;
long long dp[1001][1001], d[5];
int n, k;
int main() {
  cin >> n >> k;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    dp[i][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
    }
  }
  d[0] = 1;
  for (int i = 2; i <= k; i++) {
    d[i] = (i - 1) * (d[i - 1] + d[i - 2]);
  }
  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += (dp[n][i]) * d[i];
  }
  cout << ans;
  return 0;
}
