#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (k == 1)
    cout << "1\n";
  else if (k == 2) {
    long long ans = 7;
    for (int i = 4; i < n; i++) ans += i;
    cout << ans << endl;
  } else if (k == 3) {
    long long ans = 15;
    for (int i = 4; i < n; i++) ans += i * i;
    cout << ans << endl;
  } else {
    long long f = 24;
    for (int x = 4; x < n; x++) {
      long long n = x - 3;
      long long ans = 3 * (n * n * n) + 20 * (n * n) + 45 * n + 18 * 2;
      ans /= 2;
      f += ans;
    }
    cout << f << endl;
  }
}
