#include using namespace std; typedef long long ll; #define F first #define S second #define pii pair #define eb emplace_back #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep3(i, l, n) for (int i = l; i < n; ++i) #define chmax(a, b) a = (a >= b ? a : b) #define chmin(a, b) a = (a <= b ? a : b) #define out(a) cout << a << endl #define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl #define SZ(v) (int)v.size() #define inf (int)(1e9+7) #define abs(x) (x >= 0 ? x : -(x)) #define ceil(a, b) a / b + !!(a % b) #define FIX(a) fixed << setprecision(a) string str; int n, c, d, k; const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { cin >> n >> k; // sample 3, 5 3 if (k == 1) { out(0); return 0; } c = 1; // 3 1 2 4 5 c += n - k; // 3 4, 3 5 // 3 4 5 COMinit(); rep3(i, 2, n) { ll tmp = COM(n - k, i); if (tmp <= 0) break; c += tmp; } out(c); }