#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
using LL = unsigned long long;
LL ans[maxn][5];
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (LL i = 4; i <= 1000; i++) {
    ans[i][1] = 1;
    ans[i][2] = ans[i][1] + i * (i - 1) / 2;
    ans[i][3] = ans[i][2] + i * (i - 1) * (i - 2) / 3;
    ans[i][4] = ans[i][3] + i * (i - 1) * (i - 2) * (i - 3) / 8 * 3;
  }
  int n, k;
  cin >> n >> k;
  cout << ans[n][k] << endl;
  return 0;
}
