#include <bits/stdc++.h>
using namespace std;
int n, k;
long long C(int x, int y) {
  long long temp = 1;
  long long ans = 1;
  int y1 = y;
  while (y > 0) {
    temp *= x;
    x--;
    y--;
  }
  while (y1 > 0) {
    ans *= y1;
    y1--;
  }
  return temp / ans;
}
int main() {
  scanf("%d%d", &n, &k);
  long long temp;
  if (k == 1) {
    temp = 1;
  } else if (k == 2) {
    temp = 1 + C(n, 2);
  } else if (k == 3) {
    temp = 1 + C(n, 2) + C(n, 3) * 2;
  } else if (k == 4) {
    temp = 1 + C(n, 2) + C(n, 3) * 2 + C(n, 4) * 9;
  }
  printf("%lld\n", temp);
  return 0;
}
