#include #include using namespace std; int main(int argc, char *argv[]) { int N, K; cin >> N >> K; int ans = 0; if (K == 1) { ans = (N * (N - 1)) / 2 - 1; } else { ans = N - 1; } cout << ans << endl; return 0; }