#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
long long int f[2005][2005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    if (k == 1) {
      cout << 1 << endl;
      return 0;
    }
    if (k == 2) {
      cout << 1 + (n * (n - 1)) / 2 << endl;
      return 0;
    }
    if (k == 3) {
      cout << 1 + (n * (n - 1)) / 2 + (n * (n - 1) * (n - 2)) / 3 << endl;
      return 0;
    }
    if (k == 4) {
      cout << 1 + (n * (n - 1)) / 2 + (n * (n - 1) * (n - 2)) / 3 +
                  (3 * (n * (n - 1) * (n - 2) * (n - 3))) / 8
           << endl;
    }
  }
}
