#include <bits/stdc++.h>
using namespace std;
long long int n, k;
int main() {
  cin >> n >> k;
  if (k == 1) {
    cout << 1 << '\n';
    return 0;
  }
  if (k == 2) {
    cout << (n * (n - 1)) / 2 + 1 << '\n';
    return 0;
  }
  if (k == 3) {
    long long int p = 4;
    long long int ans = 15;
    for (int i = 4; i < n; i++) {
      ans += p * p;
      p++;
    }
    cout << ans << '\n';
    return 0;
  }
  long long int ans = 24;
  long long int c = 4, p = 13, add = 10;
  for (long long int i = 4; i < n; i++) {
    ans += c * p;
    c++;
    p += add;
    add += 3;
  }
  cout << ans << '\n';
}
