#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  for (; c > '9' || c < '0'; c = getchar())
    if (c == '-') f = -1;
  for (; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
const int N = 1005;
long long n, m, ans = 1;
int main() {
  read(n), read(m);
  if (m > 1) ans += (n - 1) * n / 2;
  if (m > 2) ans += 2 * (n - 2) * (n - 1) * n / 6;
  if (m > 3) ans += 9 * (n - 3) * (n - 2) * (n - 1) * n / 24;
  printf("%lld", ans);
  return 0;
}
