#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define eps 0.000001 #define LONG_INF 10000000000000 #define GOLD 1.61803398874989484820458 #define seg_size 65536*4 #define REP(i,n) for(long long i = 0;i < n;++i) unsigned long xor128() { static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123; unsigned long t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } int main() { long long n, k; cin >> n >> k; long long bot = 0; long long top = n * (n + 1LL) / 2LL; n -= k; top -= (n) * (n + 1LL) / 2LL; long long ans = top; if (k % 2 == 1) { ans += 1LL; } else { ans += 1LL; } cout << ans << endl; return 0; }