N,K = map(int,input().split())
s = 0
a = 0
b = N

for i in range(1,K):
    s += b - a + 1
    a += i
    b += N - i

u = 0
a = 0
b = N
for i in range(1,N+2):
    u += b - a + 1
    a += i
    b += N - i
print(u-s)