#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pl; int main() { int N, K; cin >> N >> K; ll ans = 0; if (N == 2 && K == 1)ans = 0; else { int num1 = N - K; int num2 = K - 1; ans = (num1*(num1 + 1)) / 2; if (num2 != 0)ans++; } cout << ans << endl; return 0; }