Sasha is a very happy guy, that's why he is always on the move. There are $n$ cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from $1$ to $n$ in increasing order. The distance between any two adjacent cities is equal to $1$ kilometer. Since all roads in the country are directed, it's possible to reach the city $y$ from the city $x$ only if $x < y$. 

Once Sasha decided to go on a trip around the country and to visit all $n$ cities. He will move with the help of his car, Cheetah-2677. The tank capacity of this model is $v$ liters, and it spends exactly $1$ liter of fuel for $1$ kilometer of the way. At the beginning of the journey, the tank is empty. Sasha is located in the city with the number $1$ and wants to get to the city with the number $n$. There is a gas station in each city. In the $i$-th city, the price of $1$ liter of fuel is $i$ dollars. It is obvious that at any moment of time, the tank can contain at most $v$ liters of fuel.

Sasha doesn't like to waste money, that's why he wants to know what is the minimum amount of money is needed to finish the trip if he can buy fuel in any city he wants. Help him to figure it out!


-----Input-----

The first line contains two integers $n$ and $v$ ($2 \le n \le 100$, $1 \le v \le 100$)  — the number of cities in the country and the capacity of the tank.


-----Output-----

Print one integer — the minimum amount of money that is needed to finish the trip.


-----Examples-----
Input
4 2

Output
4

Input
7 6

Output
6



-----Note-----

In the first example, Sasha can buy $2$ liters for $2$ dollars ($1$ dollar per liter) in the first city, drive to the second city, spend $1$ liter of fuel on it, then buy $1$ liter for $2$ dollars in the second city and then drive to the $4$-th city. Therefore, the answer is $1+1+2=4$.

In the second example, the capacity of the tank allows to fill the tank completely in the first city, and drive to the last city without stops in other cities.

Difficulty: EASY

Solutions:
j = str(input()).split()
s = int(j[0]) - 1
c = int(j[1])
m = 0
if s >= c:
	m = c
	for i in range(2, s - c + 2):
		m += i
else:
	m = s
print(m)


def solve(n, v):
	fuel = min(n - 1, v)
	cost = fuel
	for i in range(2, n):
		if fuel >= n - 1:
			break
		fuel += 1
		cost += i
	return cost
(n, v) = map(int, input().split())
print(solve(n, v))


(n, v) = map(int, input().split())
ans = 0
i = 1
for x in range(1, n):
	if x > v:
		i += 1
	ans += i
print(ans)


(n, v) = map(int, input().split())
if n <= v:
	print(n - 1)
elif v == n - 1:
	print(v)
else:
	k = v
	for i in range(2, n - v + 1):
		k += i
	print(k)


import sys
(n, v) = map(int, input().split())
if n <= v:
	print(n - 1)
	sys.exit()
n -= v
sum = n * (n + 1) / 2 + v - 1
print(int(sum))


(x, y) = map(int, input().split())
if x <= y:
	exit(print(x - 1))
else:
	m = x - y
	print(m * (m + 1) // 2 + (y - 1))


(n, tank) = list(map(int, input().split()))
if n - 1 == tank:
	print(tank)
elif n < tank:
	print(n - 1)
else:
	total = n - tank
	fuel = int(tank + total * (total + 1) / 2 - 1)
	print(fuel)


(n, q) = map(int, input().split())
print(int((n - q) * (n - q + 1) / 2 - 1 + q) if n - 1 > q else n - 1)


import sys
an = list(map(int, input().split()))
if an[1] >= an[0] - 1:
	print(int(an[0] - 1))
	sys.exit()
m = an[0] - an[1] - 1
print(int(an[1] + m * (m + 3) / 2))


import collections
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, A1, A2):
		pass

def gcd(a, b):
	if not b:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return b * a // gcd(b, a)

class Solution:

	def solve(self, max_fuel, N):
		dp = {1: 0}
		for i in range(1, N):
			new_dp = {}
			for (curr, spent) in dp.items():
				if curr == 0:
					continue
				curr_f = curr - 1
				for fuel in range(curr_f, max_fuel + 1):
					new_spent = spent + (fuel - curr_f) * i
					new_dp[fuel] = min(new_dp.get(fuel, float('Inf')), new_spent)
			dp = new_dp
		if 0 in dp:
			del dp[0]
		return min(dp.values())
sol = Solution()
sol2 = Solution2()
for test_case in range(1):
	(N, M) = input().split()
	out = sol.solve(int(M), int(N))
	print(str(out))


(n, v) = map(int, input().split())
s = v
for i in range(1, n - v):
	s += i + 1
if v < s:
	print(s)
else:
	print(n - 1)


(n, v) = map(int, input().split())
i = 1
su = v + 0
if n - 1 <= v:
	print(n - 1)
else:
	while n - 1 > v:
		i += 1
		n -= 1
		su += i
	print(su)


def f():
	(n, v) = map(int, input().split())
	if v > n:
		print(n - 1)
	else:
		b = n - v
		v += b * (b + 1) // 2 - 1
		print(v)
f()


(n, v) = map(int, input().split())
c = v
if v >= n:
	c = n - 1
for i in range(2, n - v + 1):
	c += i
print(c)


(n, v) = list(map(int, input().split()))
if n - 1 <= v:
	print(n - 1)
else:
	print(v + (n - v) * (n - v + 1) // 2 - 1)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	af = max([0, n - 1 - v])
	print(v + af + af * (af + 1) // 2)


def sol(n, v):
	fuel = v - 1
	total = v
	c = 2
	if v >= n:
		return n - 1
	while fuel + c < n:
		total += c
		c += 1
	return total
(n, v) = [int(x) for x in input().split()]
print(sol(n, v))


class Trip:
	(n, v) = map(int, input().split())
	counter = 0
	if v >= n - 1:
		counter = n - 1
	else:
		for i in range(1, n - v - 1 + 2):
			if i == 1:
				counter = v
			else:
				counter += i
	print(counter)


(n, v) = [int(x) for x in input().split()]
nod = n - 1
if nod <= v:
	print(nod)
else:
	c = v
	f = nod - v
	i = 2
	while i < f + 2:
		c += i
		i += 1
	print(c)


(n, capacity) = map(int, input().split())
flag = 0
price = 0
if capacity < n - 1:
	fuel = capacity
	price = capacity
else:
	flag = 1
	fuel = n - 1
	price = n - 1
i = 2
fuel -= 1
while fuel < n - i:
	if flag == 1:
		break
	if capacity - fuel <= n - i:
		price += (capacity - fuel) * i
	i += 1
print(price)


(n, v) = map(int, input().split())
print(n - 1 if v >= n - 1 else v + sum([i for i in range(2, n - v + 1)]))


(n, v) = map(int, input().split())
t = v
if v > n - 1:
	r = n - 1
else:
	r = v
for i in range(2, n + 1):
	t = t - 1
	n = n - 1
	if t < n - 1:
		r = r + (v - t) * i
		t = v
print(r)


(n, v) = map(int, input().split())
cost = v - 1
if v >= n - 1:
	print(n - 1)
else:
	for x in range(1, n - v + 1):
		cost += x
	print(cost)


(n, v) = map(int, input().split())
if n > v:
	k = n - v
	print(v - 1 + k * (k + 1) // 2)
else:
	print(n - 1)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
(n, v) = L()
cost = min(v, n - 1)
cap = cost - 1
for i in range(2, n):
	if cap < n - i:
		cap += 1
		cost += i
	cap -= 1
print(cost)
endtime = time.time()


(n, v) = map(int, input().split())
cost = [0] * n
cost = v if n > v else n - 1
for i in range(1, n - v):
	cost += i + 1
print(cost)


def f():
	arr = list(map(int, input().split()))
	money = 0
	fuel = 0
	for i in range(1, arr[0] + 1):
		if fuel < arr[0] - i:
			money += min(arr[1] - fuel, arr[0] - i) * i
			fuel += min(arr[1] - fuel, arr[0] - i)
		fuel -= 1
	print(money)
f()


import math
(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	i = n - v
	i = i * (i + 1) // 2 - 1
	print(v + i)


def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())
(n, v) = num_input()
if v >= n - 1:
	print(n - 1)
else:
	cost = v
	for i in range(2, n + 1):
		cost += i
		if n - i == v:
			break
	print(cost)


(n, v) = map(int, input().split())
if v >= n - 1:
	ans = n - 1
else:
	ans = sum(range(2, n - v + 1))
	ans += v
print(ans)


(n, v) = list(map(int, input().split()))
count = 0
if v >= n - 1:
	print(n - 1)
	exit(0)
store = 0
i = 1
while i <= n:
	if n - i > v and store == 0:
		store = v
		count += v * i
	elif store < n - i:
		count += i
		store = v
	store -= 1
	i += 1
print(count)


(n, v) = map(int, input().split())
c = min(v, n - 1)
for i in range(1, n - 1):
	d = n - i - 1
	if d < v:
		break
	c += i + 1
print(c)


import math
(n, v) = map(int, input().split())
cost = 0
vol = 0
volreqd = n - 1
for i in range(1, n + 1):
	if volreqd > 0:
		cost += min(volreqd, v - vol) * i
		(volreqd, vol) = (volreqd - min(volreqd, v - vol), vol + min(volreqd, v - vol))
	vol -= 1
print(cost)


(n, v) = map(int, input().split())
t = 1
if n > v:
	sum = v + (n - v) * (n - v + 1) / 2 - 1
	print(int(sum))
else:
	print(n - 1)


(n, v) = list(map(int, input().split()))
d = n - 1
f = 0
cost = 0
i = 1
while d > f:
	if d >= v:
		add = v - f
		f += add
		cost += i * add
	else:
		f += d
		cost += d * i
	d -= 1
	i += 1
	f -= 1
print(cost)


(n, v) = [int(i) for i in input().split()]
p = n - 1
f = 0
if v >= p:
	f = p
else:
	f = v - 1
	for i in range(1, n - v + 1, 1):
		f += i
print(f)


nv = list(map(int, input().split()))
n = nv[0] - 1
v = nv[1]
if v >= n:
	print(n)
	quit()
k = 2
money = v
while n - v > 0:
	n = n - 1
	money += k
	k += 1
print(money)


(n, v) = map(int, input().split())
t = 0
oil = 0
for i in range(1, n):
	if oil < n - i:
		fill = min(n - i, v) - oil
		oil += fill
		cost = fill * i
		t += cost
	oil -= 1
print(t)


(n, v) = [int(x) for x in input().split()]
if n <= v + 1:
	print(n - 1)
else:
	print(v + (n - v - 1) * (n - v - 2) // 2 + (n - v - 1) * 2)


(n, v) = map(int, input().split())
dis = n - 1
if v >= dis:
	print(dis)
	exit()
cost = v
for i in range(2, n - v + 1):
	cost += i
print(cost)


(n, v) = map(int, input().split())
print(sum(range(2, n - v + 1)) + min(n - 1, v))


(n, v) = map(int, input().split(' '))
res = min(n - 1, v)
for i in range(2, n - v + 1):
	res += i
print(res)


data = input().split(' ')
n = int(data[0])
v = int(data[1])
sum1 = v
if n <= v:
	sum1 = n - 1
else:
	for i in range(2, n - v + 1):
		sum1 += i
print(sum1)


list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)
(n, v) = map(int, input().split())
val = v - 1 + int((n - v) * (n - v + 1) / 2)
if n > v:
	print(val)
else:
	print(n - 1)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	count = v
	c = v
	for i in range(1, n):
		if count >= n - i:
			break
		if count < v:
			count = v
			c += i
		count -= 1
	print(c)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	no = n - 1 - v
	s = no * (2 * 2 + no - 1) // 2
	print(s + v)


(n, v) = map(int, input().split())
ans = 0
if v >= n - 1:
	ans = n - 1
else:
	ans = v
	for i in range(2, n - v + 1):
		ans += i
print(ans)


(n, v) = map(int, input().split())
if v > n:
	print(n - 1)
if v == n - 1:
	print(v)
if v == n:
	print(v - 1)
else:
	j = n
	s = v
	for i in range(2, n):
		j = j - 1
		s = s + i * 1
		if v == j - 1:
			print(s)
			break


(n, v) = map(int, input().split())

def cost_best_strategy(n, v):
	cost = min(v, n - 1)
	if n - 1 > v:
		refill_number = n - 1 - v
		refill_cost_1 = 2
		s = (2 * refill_cost_1 + (refill_number - 1) * 1) * refill_number // 2
		cost += s
	return cost
print(cost_best_strategy(n, v))


(nb_cities, fuel_limit) = [int(x) for x in input().split()]
if nb_cities - 1 <= fuel_limit:
	print(nb_cities - 1)
else:
	cost = fuel_limit - 1
	for i in range(1, nb_cities - fuel_limit + 1):
		cost += i
	print(cost)


cnt = lambda s, i: s.count(i)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
lf = lambda : list(map(int, input().split()))
(n, v) = f()
s = v
if n - 1 <= v:
	print(n - 1)
else:
	for i in range(2, n):
		if n - i == v - 1:
			break
		else:
			s += i
	print(s)


def main():
	money = 1
	[n, c] = list(map(int, input().split(' ')))
	kms = n - 1
	total = 0
	total += money * min(c, kms)
	kms -= min(c, kms)
	money += 1
	while kms != 0:
		total += money
		kms -= 1
		money += 1
	print(total)
main()


(n, l) = map(int, input().split())
if n >= l:
	b = n - 1 - l
	t = b + 1
	print(int(t * (t + 1) / 2) + l - 1)
elif n < l:
	print(n - 1)


import sys

def solve(cities, capacity):
	next_city = 1
	total_cost = 0
	fuel = min(cities - next_city, capacity)
	total_cost = fuel * next_city
	next_city += 1
	while next_city < cities - fuel + 1:
		total_cost += next_city
		next_city += 1
	return total_cost

def main():
	for line in sys.stdin:
		(cities, cap) = list(map(int, line.split()))
		break
	print(solve(cities, cap))
main()


def get():
	return list(map(int, input().split()))

def gcd(a, b):
	if b % a == 0:
		return a
	return gcd(b, a % b)
(n, m) = get()
f = min(n - 1, m)
r = n - f - 1
if r:
	f += (3 + r) * r // 2
print(f)


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
(n, k) = inp()
t = min(k, n - 1)
extra = 0
j = 2
for i in range(t + 1, n):
	extra += j
	j += 1
print(t + extra)


(d, v) = map(int, input().split())
d = d - 1
if v < d:
	k = d - v + 1
	a = v - 1 + (k + 1) * k / 2
	print(int(a))
else:
	print(d)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial

def binNumber(n, size=1):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	return ' '.join(list(map(str, a)))

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
(n, v) = isp()
b = min(n - 1, v)
for i in range(2, n - v + 1):
	b += i
print(b)


(n, v) = map(int, input().split())
if n <= v:
	print(n - 1)
	exit()
ans = v - 1 + (n - v) * (n - v + 1) // 2
print(ans)


a = input()
content = a.split()
cities = int(content[0])
tank = int(content[1])
gasr = cities - 1
cgas = 0
tgas = 0
tgasp = 0
city = 1
while tgas < gasr:
	if cgas < tank:
		cgas += 1
		tgasp += city
		tgas += 1
	else:
		city += 1
		cgas -= 1
print(tgasp)


kms = 0
(cities, fuel_capacity) = map(int, input().split())
fuel = min(fuel_capacity, cities - 1)
charge = fuel
while kms < cities - 1:
	kms += 1
	fuel -= 1
	if cities - kms - 1 > fuel:
		f = min(fuel_capacity - fuel, cities - 1 - kms - fuel)
		charge += min(fuel_capacity - fuel, cities - 1 - kms - fuel) * (kms + 1)
		fuel += f
print(charge)


(n, v) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	ans += i
	if n - i <= v:
		break
print(ans - 1 + min(n - 1, v))


(n, v) = map(int, input().split())
if v > n - 1:
	r = n - 1
else:
	r = v - 1 + (n - v) * (n - v + 1) // 2
print(r)


import sys
import math

def scan(input_type='int'):
	return list(map(int, sys.stdin.readline().strip().split()))

def solution():
	(n, v) = scan()
	if n - 1 < v:
		print(n - 1)
	else:
		r = v - 1
		for i in range(1, n - v + 1):
			r += i
		print(r)
solution()


import sys
import math
import bisect
import itertools

def main():
	(n, cap) = map(int, input().split())
	fuel = 0
	ans = 0
	for i in range(1, n + 1):
		if i > 1:
			fuel -= 1
		if fuel < n - i:
			delta = min(cap - fuel, n - i - fuel)
			ans += delta * i
			fuel += delta
	print(ans)
main()


from collections import deque
from collections import Counter
from itertools import permutations
import heapq

def counterExample():
	arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]
	counter = Counter(arr)
	top_three = counter.most_common(3)
	print(top_three)
q = deque()
import math

def main():
	(n, v) = tuple([int(i) for i in input().split()])
	d = 1
	cost = 0
	if v >= n:
		return n - 1
	else:
		cost = v
		i = 2
		while d < n - v:
			d += 1
			cost += i
			i += 1
	return cost
print(main())


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	diff = n - v
	f = v
	s = diff * (diff + 1) // 2 - 1
	print(s + f)


import math
(n, v) = map(lambda x: int(x), input().split())
result = n - 1 if n <= v else v
if n > v:
	for i in range(2, n - v + 1):
		result += i
print(result)


(n, v) = map(int, input().split(' '))
x = int(n - v - 1)
if v > n:
	result = int(n - 1)
else:
	result = int(v - 1 + (x + 1) * (x + 2) / 2)
print(result)


(n, v) = map(int, input().split())
tank = min(v, n - 1)
price = tank
for i in range(1, n + 1):
	if tank == n - i:
		break
	if tank < v:
		tank += 1
		price += i
	tank -= 1
print(price)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
	exit(0)
cost = 0
fuel = 0
for i in range(n):
	liters = min(n - 1 - i, v)
	cost += (i + 1) * liters
	fuel += liters
	if fuel >= n - 1 - i:
		print(cost)
		break
	fuel -= 1
	v -= liters
	v += 1


(b, c) = map(int, input().split())
p = 0
s = 1
t = 0
if b - 1 <= c:
	print(b - 1)
else:
	while s + t != b:
		if s == 1:
			p += c
			t += c
			s += 1
		else:
			p += s
			s += 1
			t += 1
		t -= 1
	print(p)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	total = v
	i = 2
	while n - i > v - 1:
		total += i
		i += 1
	print(total)


(a, b) = map(int, input().split())
z = a - b
if b >= a - 1:
	print(a - 1)
else:
	for i in range(2, z + 1):
		b += i
	print(b)


(n, v) = [int(c) for c in input().split()]
if v + 1 >= n:
	print(n - 1)
else:
	res = v
	for x in range(2, n - v + 1):
		res += x
	print(res)


(a, b) = map(int, input().split())
x = b - a
if b > a:
	print(a - 1)
else:
	print(int(a + x * (x + 1) / 2 - 1))


def solve(n, v):
	cost = 0
	i = 1
	b = 0
	while i < n and b < n - i:
		b_diff = min(n - i, v - b)
		b += b_diff
		cost += max(b_diff, 0) * i
		i += 1
		b -= 1
	return cost
(n, v) = map(int, input().split())
print(solve(n, v))


s = input()
s = s.split(' ')
n = int(s[0])
v = int(s[1])
if v >= n:
	print(n - 1)
elif v == n - 1:
	print(v)
else:
	s = 0
	for i in range(2, n - v + 1):
		s += i
	print(s + v)


(a, b) = list(map(int, input().split()))
if b >= a - 1:
	print(a - 1)
else:
	summ = b
	k = a - b
	for i in range(2, k + 1):
		summ += i
	print(summ)


(n, v) = map(int, input().split())
m = 1
z = 0
haz = 0
if v >= n - 1:
	print(n - 1)
	exit()
while True:
	if v + m == n:
		haz += m * (v - z)
		break
	elif v + m < n:
		haz += m * (v - z)
		z = v - 1
		m += 1
	else:
		pass
print(haz)


import sys

def getAndParseInt(num=1):
	string = sys.stdin.readline().strip()
	if num == 1:
		return int(string)
	else:
		return [int(part) for part in string.split()]

def getAndParseString(num=1, delim=''):
	string = sys.stdin.readline().strip()
	if num == 1:
		return string
	elif delim != '':
		return [part for part in string.split(delim)]
	else:
		return [part for part in string.split()]
(n, v) = getAndParseInt(2)
if v <= n - 1:
	cost = (n - v + (n - v) * (n - v)) // 2
	cost += v - 1
else:
	cost = n - 1
print(cost)


(n, v) = map(int, input().split())
(q, total, c) = (0, 0, 1)
if v >= n:
	print(n - 1)
elif v == n - 1:
	print(n - 1)
else:
	total += v
	req = n - v
	q = req * (req + 1) // 2
	total += q - 1
	print(total)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
	exit()
ans = v - 1
for i in range(1, n - v + 1):
	ans += i
print(ans)


s = input().split()
(n, v) = (int(s[0]), int(s[1]))
if n <= v:
	print(n - 1)
else:
	i = 1
	total = 0
	while n > 1:
		if i == 1:
			n -= v
			total += v
		else:
			total += i
			n -= 1
		i += 1
	print(total)


(n, v) = map(int, input().split())
cnt = min(v, n - 1)
tel = cnt
for i in range(2, n):
	tel -= 1
	rasta = n - i
	if tel < rasta:
		x = min(v - tel, rasta)
		tel += x
		cnt += x * i
print(cnt)


import sys
lines = sys.stdin.read().splitlines()

def sumOfThings(n):
	c = 2
	count = 0
	for i in range(0, n):
		count += c
		c += 1
	return count
(n, v) = [int(x) for x in lines[0].split(' ')]
if n - 1 <= v:
	print(n - 1)
else:
	print(v + sumOfThings(n - 1 - v))


(n, v) = map(int, input().split())
t = [0] + [float('inf')] * n
current_fuel = 0
for i in range(1, n + 1):
	required_gas = n - i
	fuel_to_buy = min(required_gas, v) - current_fuel
	current_fuel += fuel_to_buy - 1
	t[i] = t[i - 1] + fuel_to_buy * i
print(t[n])


(n, v) = [int(s) for s in input().split()]
k = n - v
if k <= 0:
	sum = n - 1
else:
	sum = v
for i in range(2, k + 1):
	sum += i
print(sum)


(n, k) = map(int, input().split())
f = min(n - 1, k)
if k == n - 1:
	print(k)
else:
	for i in range(1, n):
		if n - i > k:
			f += i + 1
			k += 1
		k -= 1
	print(f)


def read_nums():
	return [int(x) for x in input().split()]

def main():
	(n, v) = read_nums()
	res = 0
	cur_tank = 0
	for c in range(1, n + 1):
		need_to_by = min(v - cur_tank, n - c - cur_tank)
		res += need_to_by * c
		cur_tank += need_to_by
		cur_tank -= 1
	print(res)
main()


def ride(stop, capacity):
	cost = 0
	fuel = 0
	if stop - 1 <= capacity:
		return stop - 1
	for i in range(1, stop):
		kms = stop - i
		if fuel != 0:
			fuel = fuel - 1
		if kms <= capacity:
			cost = cost + (capacity - fuel) * i
			return cost
		elif kms > capacity:
			cost = cost + (capacity - fuel) * i
			fuel = capacity
	return cost
cc = input().split(' ')
cost = ride(int(cc[0]), int(cc[1]))
print(cost)


(n, v) = input().split()
n = int(n)
v = int(v)
cost = min(n - 1, v)
i = 2
while n - v - 1 > 0:
	cost += i
	n -= 1
	i += 1
print(cost)


inp = input().split()
numOfCities = int(inp[0], 10)
capacity = int(inp[1], 10)
currentCity = 1
currentFuel = 0
totalAmount = 0
while currentFuel < numOfCities:
	remaining = min(capacity - currentFuel, numOfCities - currentCity)
	currentFuel += remaining
	totalAmount += currentCity * remaining
	if currentCity + currentFuel >= numOfCities:
		break
	currentCity += 1
	currentFuel -= 1
print(totalAmount)


import math, sys
(n, v) = map(int, input().split())
rs = v
litre = v
i = 1
if n <= v:
	print(n - 1)
	sys.exit()
while litre < n - 1:
	i += 1
	litre = litre + 1
	rs = rs + i
print(rs)


(n, v) = map(int, input().split())
p = 0
if v <= n - 1:
	p = v
else:
	p = n - 1
t = n - 1 - p
for i in range(2, 2 + t, 1):
	p += i
print(p)


(a, b) = map(int, input().split())
if a - 1 <= b:
	print(a - 1)
	exit()
x = a - b
print(b - 1 + x * (x + 1) // 2)


(n, v) = map(int, input().split())
if n - v == 1:
	print(v)
elif n - v <= 0:
	print(n - 1)
else:
	ans = v - 1
	s = (n - v) * (n - v + 1) // 2
	ans += s
	print(ans)


(n, v) = [int(x) for x in input().split()]

def price(n, v):
	if v >= n - 1:
		return n - 1
	price = v
	l = v
	for i in range(2, n):
		price = price + i
		l += 1
		if l == n - 1:
			return price
print(price(n, v))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, v) = nninp()
if n - 1 <= v:
	p(n - 1)
else:
	curr = 1
	ans = v
	while n - curr != v:
		curr += 1
		ans += curr
	p(ans)


(n, v) = input().split()
n = int(n)
v = int(v)
if n <= v:
	print(n - 1)
else:
	summ = v
	for i in range(n - v - 1):
		summ += i + 2
	print(summ)


(a, b) = map(int, input().split())
k = 0
if a - 1 <= b:
	print(a - 1)
else:
	k = b
	l = a - b
	for i in range(1, l):
		k += i + 1
	print(k)


(n, v) = map(int, input().split())
money = 0
fuel = 0
if n == 2:
	print(1)
elif n - v == 1:
	print(v)
elif n == v:
	print(v - 1)
elif v > n:
	print(n - 1)
else:
	money = v
	fuel = v
	for i in range(2, n + 1):
		fuel -= 1
		if fuel != v and fuel != n - i:
			if v <= n - i:
				money += i * (v - fuel)
				fuel = v
			else:
				money += i * (n - i - fuel)
				fuel = n - i
	print(money)


(n, v) = map(int, input().split())
ans = v
if v >= n - 1:
	print(n - 1)
else:
	d = n - 1 - v
	ans += (d + 1) * (d + 2) // 2 - 1
	print(ans)


(n, v) = [int(x) for x in input().split()]
dist = n - 1
ans = -1
if dist <= v:
	ans = dist
else:
	t = n - v
	ans = v + t * (1 + t) // 2 - 1
print(ans)


ch = input()
l = ch.split()
n = int(l[0]) - 1
v = int(l[1])
s = 0
if n <= v:
	s = s + n
	print(s)
else:
	s = s + v
	i = 2
	j = n - v
	while j != 0:
		s = s + i
		i = i + 1
		j = j - 1
	print(s)


(n, v) = map(int, input().split())
petrol = n - 1
if petrol > v:
	ans = v
	i = 2
	petrol -= v
	while petrol:
		ans += i
		petrol -= 1
		i += 1
	print(ans)
else:
	print(petrol)


(n, v) = (int(i) for i in input().split())
i = 1
capacity = 0
count = 0
while i != n:
	if capacity < n - i:
		if v > n - i:
			count += (n - i - capacity) * i
			capacity += n - i
		else:
			count = count + (v - capacity) * i
			capacity = v
	i += 1
	capacity -= 1
print(count)


(a, b) = map(int, input().split())
dollars = 0
liters = 0
if b == a - 1:
	print(b)
elif b >= a:
	print(a - 1)
else:
	liters = b
	dollars = b
	for side in range(1, a):
		liters -= 1
		if liters < a - side - 1:
			liters += 1
			dollars += side + 1
		if liters == a - side - 1:
			break
	print(dollars)


(a, b) = map(int, input().split())
if b >= a:
	print(a - 1)
else:
	s = a - b - 1
	q = b
	i = 2
	j = 2
	while j < s + 2:
		q += j
		j += 1
	print(q)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	result = v - 1
	i = 1
	while i <= n - v:
		result += i
		i += 1
	print(result)


(n, v) = map(int, input().split())
price = 0
if v >= n:
	print(n - 1)
else:
	price = v
	quant = n - v
	for i in range(2, quant + 1):
		price += i
	print(price)


from operator import itemgetter
(n, v) = list(map(int, input().split()))
if v >= n - 1:
	ans = n - 1
else:
	ans = v + (2 + (2 + n - v - 2)) * (n - v - 1) // 2
print(ans)


(n, v) = input().split()
n = int(n)
v = int(v)
i = 2
j = min(n - 1, v)
res = j
j += 1
while j < n:
	res += i
	i += 1
	j += 1
print(res)


import sys
inn = lambda : input().strip()
(N, V) = map(int, inn().split(' '))
if N == 1:
	print(0)
	sys.exit()
answer = 0
if N - 1 <= V:
	answer = N - 1
elif N - 1 >= V:
	answer = V
for cost in range(2, N - V + 1):
	answer += cost
print(answer)


def sol():
	(n, w) = list(map(int, input().split()))
	if n <= w:
		print(n - 1)
		return 0
	d = w
	t = w
	for i in range(1, n - w):
		t += i + 1
	print(t)
sol()


(n, v) = [int(a) for a in input().split(' ')]
ans = 0
current = 0
for i in range(1, n + 1):
	mn = min([v, n - i])
	p = mn - current
	if p <= 0:
		break
	else:
		ans += p * i
		current = mn - 1
print(ans)


(n, m) = map(int, input().split())
t = m
if m >= n - 1:
	print(n - 1)
else:
	for i in range(2, n - m + 1):
		t = t + i
	print(t)


def __starting_point():
	nums = input().split()
	n = int(nums[0])
	v = int(nums[1])
	if n < v + 2:
		print(n - 1)
	else:
		print(int(v - 1 + (n - v) * (n - v + 1) / 2))
__starting_point()


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
(n, v) = inm()
if n < v:
	print(n - 1)
else:
	x = n - v
	print(x * (x + 1) // 2 + v - 1)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
	exit(0)
p = v
for i in range(2, n - v + 1):
	p += i
print(p)


(n, v) = map(int, input().strip().split())
totcost = min(v, n - 1)
for i in range(2, n - v + 1):
	totcost += i
print(totcost)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, v) = get_int_list()
fuel_req = n - 1
if fuel_req <= v:
	print(fuel_req)
else:
	fuel_req -= v
	more = (fuel_req + 1) * (fuel_req + 2) // 2 - 1
	print(more + v)


def solve(n, v):
	l = n - 1
	if l <= v:
		return l
	else:
		x = n - v
		s = (2 + x) * (x - 1) // 2
		return s + v

def main():
	(n, v) = list(map(int, input().split()))
	print(solve(n, v))
main()


(n, v) = list(map(int, input().split()))
sm = v
if n > v:
	for i in range(2, n - v + 1):
		sm += i
	print(sm)
else:
	print(n - 1)


s = input().split(' ')
n = int(s[0])
v = int(s[1])
if n - 1 < v:
	print(n - 1)
else:
	print(v + ((n - v) * (n - v + 1) // 2 - 1))


(n, v) = [int(x) for x in input().split(' ')]
f = 0
c = 0
if v >= n - 1:
	ans = n - 1
else:
	ans = v + (2 + n - v) * (n - v - 1) // 2
print(ans)


ii = lambda : int(input())
iin = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
(n, v) = iin()
i = 0
ans = 0
if v >= n - 1:
	print(n - 1)
else:
	x = v
	i = 2
	ans += v
	while n:
		if v < n:
			ans += i
			i += 1
		if v > n - i:
			break
	print(ans)


s = input().split()
n = int(s[0])
a = int(s[1])
if a < n:
	p = a
	i = 2
	while i <= n - a:
		p += i
		i += 1
	print(p)
else:
	print(n - 1)


(n, v) = map(int, input().split())
d = n - 1
total = min(d, v)
for i in range(2, n - v + 1):
	total += i
print(total)


(n, v) = map(int, input().split())
a = v
l = n - 1 - v
if v >= n:
	print(n - 1)
else:
	cost = a + ((l + 1) * (l + 2) // 2 - 1)
	print(cost)


(n, m) = map(int, input().split())
if m >= n - 1:
	print(n - 1)
else:
	rem = 0
	cost = m
	reach = m
	for i in range(1, n):
		if reach + i < n:
			cost = cost + (i + 1)
	print(cost)


def solve(n, v):
	if v >= n:
		print(n - 1)
		return
	(ans, f) = (0, 0)
	for i in range(1, n + 1):
		t = v - f
		ans += i * t
		f += t
		if i + f >= n:
			break
		f -= 1
	print(ans)
(n, v) = list(map(int, input().split()))
solve(n, v)


(n, v) = list(map(int, input().split()))
total_cost = 0
i = 1
if v >= n - 1:
	print(n - 1)
else:
	total_cost = v
	while n - i != v:
		i += 1
		total_cost += i
	print(total_cost)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	summ = v
	j = 2
	while v < n - 1:
		n -= 1
		summ += j
		j += 1
	print(summ)


(n, v) = map(int, input().split())
d = n
i = 1
m = v * i
if i + v >= n:
	print(n - i)
else:
	while n - v != 1:
		n = n - 1
		i = i + 1
		m = m + 1 * i
	print(m)


import sys
input = sys.stdin.readline

def inlt():
	return list(map(int, input().split()))

def solve(n, v):
	cost = 0
	cur = 1
	for i in range(n):
		cur -= 1
		fill = min(n - 1 - (i + cur), v - cur)
		if fill <= 0:
			break
		cur += fill
		cost += (i + 1) * fill
	return cost
nv = inlt()
print(solve(nv[0], nv[1]))


(citys, cap) = map(int, input().split())
if citys - 1 <= cap:
	print(citys - 1)
else:
	n = citys - cap
	print(n * (n + 1) // 2 + cap - 1)


(n, v) = map(int, input().split())
n -= 1
if n <= v:
	print(n)
else:
	c = n - v
	print(n + c * (c + 1) // 2)


def solve(n, v):
	if v >= n:
		print(n - 1)
		return
	ans = v - 1
	for i in range(1, n - v + 1):
		ans += i
	print(ans)
(n, v) = list(map(int, input().split()))
solve(n, v)


(n, v) = map(int, input().split())
if v >= n:
	print(n - 1)
else:
	total = n - 1 - v
	tk = v
	for i in range(2, n + 1):
		if total <= 0:
			break
		tk += i
		total -= 1
	print(tk)


(n, v) = map(int, input().split())
s = 0
if n <= v + 1:
	print(n - 1)
	exit()
kl = v
s = v
for i in range(2, n):
	if kl >= n - 1:
		break
	kl += 1
	s += i
print(s)


(n, v) = map(int, input().split())
n -= 1
ans = min(n, v)
for i in range(1, n - v + 1):
	ans += i + 1
print(ans)


(n, v) = map(int, input().split())
cost = 0
if v >= n - 1:
	cost = n - 1
else:
	cost = v
	l = v
	for i in range(2, n):
		cost += i
		l += 1
		if l >= n - 1:
			break
print(cost)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))
(n, v) = mi()
dist = n - 1
if v >= dist:
	print(dist)
else:
	off = dist - v
	prices = [i + 2 for i in range(off)]
	print(v + sum(prices))


(n, v) = map(int, input().split())

def cost(n, v):
	costs = [i for i in range(v)]
	for i in range(1 + v, n + 1):
		new_cost = min([c + (i - v) * (v - idx) for (idx, c) in enumerate(costs)])
		costs = costs[1:] + [new_cost]
	if n > v:
		return costs[-1]
	return costs[n - 1]
print(cost(n, v))


(n, v) = map(int, input().strip().split())
if v >= n - 1:
	print(n - 1)
else:
	x = n - v
	ans = v + x * (x + 1) // 2 - 1
	print(ans)


(n, v) = map(int, input().split())
count = 0
ans = 0
if n == v + 1:
	print(v)
elif n == v:
	print(v - 1)
elif n < v:
	print(n - 1)
else:
	i = 1
	ans += v
	d = n - 1 - v
	while d != 0:
		i = i + 1
		ans = ans + i
		d = d - 1
	print(ans)


(a, b) = map(int, input().split())
ans = b - 1
if b > a - 1:
	print(a - 1)
else:
	i = 1
	while i <= a - b:
		ans += i
		i += 1
	print(ans)


(n, v) = map(int, input().split())
cost = 0
fuel = 0
if v >= n - 1:
	print(n - 1)
else:
	for i in range(1, n + 1):
		if i == n:
			print(cost)
			break
		else:
			if i != 1:
				fuel -= 1
			dist = n - i
			if fuel >= dist:
				print(cost)
				break
			else:
				cost += (v - fuel) * i
				fuel += v - fuel


(a, b) = map(int, input().split())
n = a - 1
if n <= b:
	print(n)
else:
	print(b - 1 + (n - b + 1) * (n - b + 2) // 2)


(n, v) = map(int, input().split())
res = 0
f = 0
for i in range(1, n + 1):
	if f < v:
		add = min(v, n - i) - f
		if add > 0:
			f += add
			res += i * add
	f -= 1
print(res)


(n, v) = map(int, input().split())
d = min(n, v)
print(d + (n - d) * (n - d + 1) // 2 - 1)


from heapq import *
(n, v) = map(int, input().split())
h = []
res = 0
for i in range(n - 1):
	while len(h) < v:
		heappush(h, i + 1)
	res += heappop(h)
print(res)


(n, v) = map(int, input().split())
k = 0
k = k + v
p = n - 1
if p <= v:
	print(p)
elif p > v:
	e = p - v + 1
	w = e * (e + 1) // 2
	w = w - 1
	k = k + w
	print(k)


(n, v) = map(int, input().split())
pneeded = n - 1 - v
cost = v
if n - 1 >= v:
	for x in range(2, n):
		if pneeded <= 0:
			break
		else:
			cost += x
			pneeded -= 1
else:
	cost = n - 1
print(cost)


(n, v) = input().split()
n = int(n)
v = int(v)
if n <= v:
	print(n - 1)
else:
	rest = n - v
	sums = v - 1
	sums += rest * (rest + 1) // 2
	print(sums)


def f(n, v):
	cost = 0
	tank = 0
	for i in range(1, n + 1):
		if i + tank < n:
			add = min(v - tank, n - i - tank)
			cost += add * i
			tank += add
		tank -= 1
	assert tank == -1
	return cost
assert f(4, 2) == 4
assert f(7, 6) == 6
assert f(10, 3) == 30
(n, v) = map(int, input().split())
ans = f(n, v)
print(ans)


(n, v) = map(int, input().split())
original_volume = v
current_position = 1
cost = original_volume
if original_volume >= n:
	print(n - 1)
else:
	for i in range(2, n + 1):
		current_position += 1
		v -= 1
		if current_position + v >= n:
			break
		else:
			v += 1
			cost += i
	print(cost)


(A, B) = input().split()
n = int(A)
m = int(B)
sum = 0
sum += min(n - 1, m)
for i in range(2, n):
	if n - i > m - 1:
		sum += i
print(sum)


inp = list(map(int, input().split()))
dist = inp[0] - 1
cost = inp[1] if inp[0] > inp[1] else dist
if inp[1] >= dist:
	print(cost)
else:
	delta = dist - inp[1] + 1
	x = int(delta * (delta + 1) / 2) - 1
	cost += x
	print(cost)


(city, capacity) = input().split()
city = int(city)
capacity = int(capacity)
cost = 0
if capacity == city - 1:
	cost = capacity
elif capacity >= city:
	cost = city - 1
else:
	cost += capacity
	for i in range(2, city - capacity + 1):
		cost += i
print(cost)


(n, v) = input().split()
n = int(n)
v = int(v)
if n > v:
	cost = v + sum(range(2, n - v + 1))
	print(cost)
else:
	print(n - 1)


(n, v) = map(int, input().split())
rs = 0
fuel = 1
dis = n
i = -1
while dis > 0:
	i += 1
	if fuel < dis and i != 0:
		them = min(dis - fuel, v - fuel)
		fuel += them
		rs += them * i
	fuel -= 1
	dis -= 1
print(rs)


(cities, capacity) = map(int, input().split())
result = 0
actual_fuel = 0
for i in range(1, cities + 1):
	if actual_fuel:
		actual_fuel -= 1
	diff = capacity - actual_fuel
	path = cities - i
	if diff <= path:
		actual_fuel += diff
		result += diff * i
	else:
		actual_fuel += path
		result += path * i
	if actual_fuel == path:
		break
print(result)


import sys
inp = sys.stdin.readline().split(' ')
n = int(inp[0])
v = int(inp[1])
ans = v
km = n - 1
if km <= v:
	ans = km
else:
	vNow = v
	coins = 1
	while km > 0:
		coins = coins + 1
		vNow = vNow - 1
		if vNow < km - 1:
			vNow = vNow + 1
			ans = ans + coins
		km = km - 1
print(ans)


def fuel_amount(i, n, v, existing_fuel):
	remaining_distance = n - i
	if existing_fuel >= remaining_distance:
		return 0
	elif existing_fuel < remaining_distance:
		if remaining_distance > v:
			return v - existing_fuel
		else:
			return remaining_distance - existing_fuel
(n, v) = [*map(int, input().split())]
total_money = 0
existing_fuel = 1
for i in range(1, n + 1):
	existing_fuel -= 1
	temp1 = fuel_amount(i, n, v, existing_fuel)
	total_money += temp1 * i
	existing_fuel += temp1
print(total_money)


x = list(map(int, input().split()))
v = x[1]
n = x[0]
if x[1] + 1 >= x[0]:
	print(int(x[0] - 1))
else:
	s = x[1] - 1 + (n - v) * (n - v + 1) / 2
	print(int(s))


(n, v) = map(int, input().strip().split())
if v < n - 1:
	price = v
else:
	price = n - 1
i = 2
while i < n - v + 1:
	price += i
	i += 1
print(price)


(n, v) = input().split()
n = int(n)
v = int(v)
if n <= v:
	print(n - 1)
	exit()
alpha = n - v - 1
sum = v
i = 2
while alpha > 0:
	sum = sum + i
	i = i + 1
	alpha = alpha - 1
print(sum)


def get_min(n_cities, cap_tank):
	if n_cities <= cap_tank:
		return n_cities - 1
	curr_lit = cap_tank - 1
	dollars = cap_tank
	i_city = 2
	while i_city <= n_cities:
		if curr_lit < n_cities - i_city and curr_lit < cap_tank:
			dollars += i_city * (cap_tank - curr_lit)
			curr_lit += cap_tank - curr_lit
		i_city += 1
		curr_lit -= 1
	return dollars
ls = [int(i) for i in input().split()]
print(get_min(ls[0], ls[1]))


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	(n, v) = map(int, sys.stdin.readline().split(' '))
	ans = 0
	pe = 0
	for i in range(1, n + 1):
		dist = n - i
		if pe < dist:
			ans += (min(v, dist) - pe) * i
			pe += min(v, dist) - pe
		pe -= 1
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


(n, v) = map(int, input().split())
tank = min(v, n - 1)
if n - 1 > tank:
	tank += sum([i + 2 for i in range(n - 1 - tank)])
print(tank)


l = [int(x) for x in input().split()]
n = l[0]
c = l[1]
if c > n - 1:
	print(n - 1)
else:
	rate = 1 * c
	for i in range(1, n):
		if c == n - i:
			print(rate)
			break
		rate = rate + i + 1


(n, v) = map(int, input().split(' '))
lm = n - 1
price = 1
output = 0
used = 0
if lm <= v:
	output = lm * price
else:
	output = v * price
	rest = lm - v
	price += 1
	while rest > 0:
		output += price
		rest -= 1
		price += 1
print(output)


import copy
import fractions
import itertools
import numbers
import string
import sys

def to_basex(num, x):
	while num > 0:
		yield (num % x)
		num //= x

def from_basex(it, x):
	ret = 0
	p = 1
	for d in it:
		ret += d * p
		p *= x
	return ret

def core():
	(n, v) = [int(x) for x in input().split()]
	ans = min(v, n - 1)
	if n - v > 1:
		ans += (2 + n - v) * (n - v - 2 + 1) // 2
	print(ans)
core()


def main():
	[n_cities, capacity] = [int(_) for _ in input().split()]
	needed_litres = n_cities - 1
	city = 1
	bought_litres = min(capacity, needed_litres)
	money = bought_litres
	while bought_litres < needed_litres:
		city += 1
		bought_litres += 1
		money += city
	print(money)
main()


(n, m) = map(int, input().split())
n -= 1
su = m
i = 2
if m >= n:
	print(n)
	quit()
while m < n:
	m += 1
	su += i
	i += 1
print(su)


(n, v) = map(int, input().split())
if n > v:
	c = v
	r = n - 1 - v
	p = 2
	for i in range(r):
		c += p
		p += 1
	print(c)
else:
	print(n - 1)


v = list(map(int, input().split(' ')))
n = v[0]
v = v[1]
diff = n - v
if v >= n:
	print(n - 1)
elif diff <= 0:
	print(v)
else:
	print(sum(list(range(2, diff + 1))) + v)


nums = input().split()
n = int(nums[0])
v = int(nums[1])
dp = [float('inf') for i in range(n + 1)]
dp[0] = 0
dp[1] = 0
cost = v
if n - 1 <= v:
	print(n - 1)
else:
	for i in range(2, n):
		if n - i == v:
			cost += i
			break
		else:
			cost += i
	print(cost)


nv = list(map(int, input().rstrip().split()))
n = nv[0]
v = nv[1]
c = 0
cprev = 0
ctot = 0
ans = 0
i = 1
while i < n and ctot != n - 1:
	if n > v:
		ans = ans + i * (v - c)
		ctot = ctot + v - c
		c = v - 1
	else:
		ans = n - 1
		break
	i = i + 1
print(ans)


(n, v) = map(int, input().split())
ANS = 0
NOW = 1
tank = 0
distance = n - 1
if distance <= v:
	print(distance)
else:
	ANS = v
	for i in range(distance - v):
		ANS += i + 2
	print(ANS)


entrada = input()
array = [int(x) for x in entrada.split()]
(n, v) = (array[0], array[1])
fuel_needed = n - 1
fuel_left = 0
cost = 0
for i in range(1, n + 1):
	if fuel_left >= fuel_needed:
		break
	adding = min(v - fuel_left, fuel_needed - fuel_left)
	cost += i * adding
	fuel_needed -= 1
	fuel_left = fuel_left + adding - 1
print(cost)


(n, v) = [int(x) for x in input().split()]
if n - 1 <= v:
	print('{}'.format(n - 1))
else:
	ans = v
	n = n - v - 1
	nx = 2
	while n > 0:
		ans = ans + nx
		nx = nx + 1
		n = n - 1
	print('{}'.format(ans))


def main():
	(n, v) = map(int, input().split(' '))
	n_coins = v
	capacity = v - 1
	if v >= n:
		print(n - 1)
		exit()
	for i in range(2, n + 1):
		if n - i > v:
			n_coins += i * (v - capacity)
			capacity = v
		else:
			if n - i > capacity:
				n_coins += i * (n - i - capacity)
				capacity = n - i
			break
		capacity -= 1
	print(n_coins)
main()


(n, v) = map(int, input().split(' '))
fuel_to_buy = n - 1
out = min(fuel_to_buy, v)
fuel_to_buy -= out
i = 2
while i <= n and fuel_to_buy > 0:
	out += i
	fuel_to_buy -= 1
	i += 1
print(out)


import os
import sys
import math
import collections
import cmath

def mp():
	return map(int, input().split())

def inp():
	return input()
(n, m) = mp()
count = min(n - 1, m)
cost = count
i = 2
while count < n - 1:
	cost += i
	count += 1
	i += 1
print(cost)


def solve(n, v):
	if n - 1 < v:
		print(n - 1)
		return
	result = v - 1
	for i in range(1, n - v + 1):
		result += i
	print(result)
	return
(n, v) = map(int, input().split())
solve(n, v)


i = 0
city = 1
(n, v) = map(int, input().split())
if v >= n - 1:
	i = n - 1
else:
	i = v
	for j in range(n - 1):
		city += 1
		i += city
		if v == n - city:
			break
print(i)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
(n, v) = I()
if v >= n - 1:
	print(n - 1)
else:
	r = v
	c = v
	for x in range(2, n + 1):
		r -= 1
		if r >= n - x:
			break
		r += 1
		c += x
	print(c)


(n, m) = map(int, input().split())
count = min(n - 1, m)
cost = count
i = 2
while count < n - 1:
	cost += i
	count += 1
	i += 1
print(cost)


a = list(map(int, input().split()))
(n, v) = (a[0], a[1])
b = n - 1
c = 0
if b == v or b < v:
	print(b)
else:
	c = c + v
	d = b - v
	for i in range(d):
		c = c + (i + 2)
	print(c)


def main():
	(n, v) = map(int, input().split())
	tank = 0
	price = 0
	for i in range(1, n):
		if tank < n - i:
			tobuy = min(v - tank, n - tank - i)
			price += tobuy * i
			tank += tobuy
		tank -= 1
	print(price)
main()


(n, v) = map(int, input().split(' '))
if v >= n - 1:
	print(min(n - 1, v))
else:
	print((n - v) * (n - v + 1) // 2 + v - 1)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, v) = I()
if v >= n:
	print(n - 1)
	exit()
d = v
dist = v + 1
r = n - dist
print((r + 1) * (r + 2) // 2 - 1 + v)


import sys
s1 = sys.stdin.readline().rstrip().split(' ')
n = int(s1[0])
v = int(s1[1])
leng = n - 1
count_ref = leng - v
val = v
last = n - v
if v < n:
	if count_ref == 1:
		val += 2
	elif count_ref == 0:
		val = v
	else:
		val += (2 + last) / 2 * (last - 1)
else:
	val = n - 1
print(int(val))


(n, v) = map(int, input().split())
if v > n - 2:
	print(n - 1)
else:
	m = n - v
	print(v + (m + 2) * (m - 1) // 2)


from sys import stdin, stdout
(n, v) = map(int, stdin.readline().split())
min_cost = min(n - 1, v)
if n <= v:
	stdout.write(str(n - 1) + '\n')
else:
	for i in range(2, n + 1):
		v = v - 1
		if n - i == v:
			break
		else:
			v = v + 1
			min_cost += i
	stdout.write(str(min_cost) + '\n')


(N_cities, FuelCap) = list(map(int, input().split()))
if FuelCap >= N_cities - 1:
	print(N_cities - 1)
else:
	n = N_cities - FuelCap
	minCost = FuelCap + n * (n + 1) / 2 - 1
	print(int(minCost))


l1 = [int(x) for x in input().split()]
n = l1[0]
v = l1[1]
if v >= n:
	print(n - 1)
else:
	k = n - v
	print(v + k * (k + 1) // 2 - 1)


input_num = input()
input_num = input_num.split(' ')
n = int(input_num[0])
capacity = int(input_num[1])
needed_liter = n - 1
price = min(needed_liter, capacity)
for i in range(2, n + 1):
	needed_liter -= 1
	if needed_liter >= capacity:
		price += i
print(price)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(a, b) = zz()
c = b
if b >= a:
	print(a - 1)
	exit()
for i in range(2, a - b + 1):
	c += i
print(c)


(n, v) = map(int, input().split())
cost = n - 1
if v < n:
	temp = n - v
	cost = temp * (temp + 1) // 2 + v - 1
print(cost)


k = input().split()
for i in range(2):
	k[i] = int(k[i]) - 1
if k[0] - 1 <= k[1]:
	print(k[0])
else:
	print(int(k[0] * (k[0] + 1) // 2 - k[1] * (k[0] - 1 - (k[1] - 1) / 2)))


(n, v) = map(int, input().split())
d = n - v
if d <= 0:
	print(n - 1)
else:
	sum = 0
	sum = sum + v
	a = d * (d + 1) // 2
	sum = sum + a - 1
	print(sum)


(n, v) = map(int, input().split())
fl = 0
m = 0
for i in range(1, n):
	if v < n - i:
		if fl < v:
			m += i * (v - fl)
			fl = v
	elif fl < n - i:
		m += i * (n - i - fl)
		fl = n - i
	fl -= 1
print(m)


def ans(n, v):
	cnt = 0
	if v >= n:
		return n - 1
	else:
		cnt += v
		for i in range(1, n - v + 1):
			cnt += i
		return cnt - 1
nv = list(map(int, input().strip().split()))
(n, v) = (nv[0], nv[1])
print(ans(n, v))


(n, v) = [int(x) for x in input().split()]
s = v
if v >= n - 1:
	print(n - 1)
else:
	t = n - v
	res = t * (t + 1) // 2
	print(res + (v - 1))


(n, v) = map(int, input().split())
if n == v + 1:
	print(v)
elif n < v + 1:
	print(n - 1)
else:
	c = v
	x = n - v
	for i in range(1, x):
		c += 1 + i
	print(c)


(n, v) = map(int, input().split())
cost = [1] * v + list(range(2, n))
print(sum(cost[:n - 1]))


x = list(map(int, input().split()))
i = 1
v = 0
city = x[0]
volume = x[1]
price = 0
while i < city:
	while v < volume and v < city - i:
		price += i
		v += 1
	i += 1
	v -= 1
print(price)


def petrol(n, l):
	total = l
	cities = n - l
	if cities <= 1:
		if l >= n:
			return n - 1
		return l
	for i in range(2, cities + 1):
		total += i
	return total
(n, l) = map(int, input().split())
print(petrol(n, l))


(n, v) = map(int, input().split())
start = 1
if n - start <= v:
	print(n - start)
else:
	cost = v
	mul = 2
	while n - start > v:
		cost += mul
		start += 1
		mul += 1
	print(cost)


(n, v) = map(int, input().split())
num = max(n - v, 0)
fuel = min(v, n) + int(num * (num + 1) // 2) - 1
print(fuel)


(n, v) = [int(v) for v in input().split()]
m = 0
cur = 0
for i in range(n):
	need = n - i - 1 - cur
	if need <= 0:
		break
	bought = min(need, v - cur)
	m += bought * (i + 1)
	cur += bought - 1
print(m)


(N, V) = map(int, input().split())
Fuel = 0
Fuel_needed = N - 1
money_spent = 0
for i in range(1, N + 1):
	buy = min(Fuel_needed, V - Fuel)
	money_spent += i * buy
	Fuel += buy
	Fuel_needed -= buy
	Fuel -= 1
assert Fuel == -1
print(money_spent)


(n, v) = (int(x) for x in input().split())
cash = 0
b = 0
if v >= n:
	print(n - 1)
else:
	cash += v
	b += v
	for i in range(1, n - 1):
		if n - i <= b:
			print(cash)
			break
		else:
			cash += i + 1
	else:
		print(cash)


from sys import stdin
(n, v) = list(map(int, stdin.readline().split()))
total = 0
c = 0
for i in range(1, n + 1):
	if n - i <= c:
		break
	if c < v:
		total += i * min(v - c, n - i)
		c = v
	c -= 1
print(total)


def sashaAndHisTrip(n, v):
	d = v
	money = v
	if n - 1 < v:
		money = n - 1
		return money
	else:
		for i in range(2, n):
			d = d - 1
			if d == n - i:
				return money
			else:
				buy = v - d
				money += buy * i
				d += buy
	return money
(n, v) = map(int, input().split())
print(sashaAndHisTrip(n, v))


[N, V] = list(map(int, input().split()))
j = N - 1
i = 2
j -= min(N - 1, V)
cost = min(N - 1, V)
while j > 0:
	j -= 1
	cost += i
	i += 1
print(int(cost))


(n, v) = map(int, input().split())
c = 0
if v >= n:
	print(n - 1)
elif v == n - 1:
	print(v)
else:
	t = v
	c = v
	f = 2
	while f < n:
		t = t - 1
		c = c + f
		if n - f == v:
			break
		f = f + 1
	print(c)


(n, r) = map(int, input().strip().split())
if r <= n:
	k = r + (2 * 2 + n - r - 2) * (n - r - 1) // 2
else:
	k = n - 1
print(k)


(n, v) = map(int, input().split())
init_amount = min(n - 1, v)
dist = n - 1 - init_amount
if dist > 0:
	init_amount += (dist + 1) * (dist + 2) // 2 - 1
print(init_amount)


def io():
	return map(int, input().split())

def op():
	return list(map(int, input().split()))
(n, v) = io()
ans = min(v, n - 1)
c = 2
for i in range(n - v - 1):
	ans += c
	c += 1
print(ans)


(cities, fuel) = map(int, input().split())
pos = 1
if fuel >= cities:
	money = cities - 1
else:
	money = fuel
while cities - pos - fuel > 0:
	pos += 1
	money += pos
print(money)


line = input()
words = []
for word in line.split():
	words.append(word)
length = int(words[0])
capacity = int(words[1])
fuel = min(capacity - 1, length - 2)
price = min(capacity, length - 1)
for i in range(length - capacity - 1):
	needed = capacity - fuel
	price += needed * (i + 2)
	fuel = capacity - 1
print(price)


a = input().split()
n = int(a[0])
v = int(a[1])
res = 0
if v == n:
	print(n - 1)
	exit()
if n < v:
	print(n - 1)
	exit()
if n > v:
	res = v
	for i in range(n - v - 1):
		res = res + i + 2
print(res)


def check(city, tank):
	in_tank = 0
	cost = 0
	for i in range(1, city):
		if in_tank < city - i and in_tank < tank:
			cost += i * min((tank - in_tank, city - i - in_tank))
			in_tank += tank - in_tank
			in_tank -= 1
	return cost
n = input().split()
city = int(n[0])
tank = int(n[1])
print(check(city, tank))


(n, v) = map(int, input().split())
if n <= v or n - 1 == v:
	print(n - 1)
else:
	cost = v
	fuel = v
	city = n - 1
	m = 2
	for i in range(n):
		fuel -= 1
		cost += m
		fuel += 1
		city -= 1
		if fuel == city:
			break
		m += 1
	print(cost)


def rd():
	return list(map(int, input().split()))

def solve():
	(n, v) = rd()
	cur = p = 0
	for i in range(1, n + 1):
		if cur < v and cur < n - i:
			p += min(v - cur, n - i - cur) * i
			cur = v
		cur -= 1
	print(p)
solve()


t = list(map(int, input('').strip(' ').split(' ')))
n = t[0]
v = t[1]
k = n - v
if n == 1:
	price = 0
elif v >= n - 1:
	price = n - 1
else:
	price = int(k * (k + 1) / 2) - 1 + v
print(price)


(n, v) = map(int, input().split())
n -= 1
if n <= v:
	print(n)
	exit(0)
else:
	i = 2
	sm = v
	n -= v
	while n > 0:
		sm += i
		n -= 1
		i += 1
	print(sm)


def solve(n: int, v: int) -> int:
	if n <= v:
		return n - 1
	else:
		return v + (n - v) * (n - v + 1) // 2 - 1
print(solve(*map(int, input().split())))


s = input()
s = s.split()
n = int(s[0])
v = int(s[1])
ans = 0
n -= 1
if v >= n:
	ans += n
else:
	i = 2
	j = v
	ans += v
	while n - j > 0:
		ans += i
		j += 1
		i += 1
print(ans)


def main():
	(n, v) = map(int, input().split())
	(curr_fuel, total_cost) = (0, 0)
	for i in range(n):
		if n - i - 1 > curr_fuel:
			need_fuel = min(v - curr_fuel, n - i - 1 - curr_fuel)
			curr_fuel += need_fuel
			total_cost += (i + 1) * need_fuel
		curr_fuel -= 1
	print(total_cost)
main()


(n, v) = map(int, input().split())
total = n - 1
price = 0
if v >= n - 1:
	print(n - 1)
else:
	total = n - v - 1
	print(total * (total + 1) // 2 - 1 + total + 1 + v)


(n, v) = [int(x) for x in input().split()]
if v < n:
	s = v
	buk = v
	for i in range(2, n + 1):
		buk -= 1
		if n - i > buk:
			s += i
			buk += 1
else:
	s = n - 1
	buk = n
print(s)


(n, v) = map(int, input().split())
temp = v - 1
sum = min(v, n - 1)
for i in range(2, n + 1):
	if temp < v and temp < n - i:
		sum += (v - temp) * i
		temp = v
	temp -= 1
print(sum)


(n, m) = map(int, input().split())
a = n - m
if a <= 0:
	print(n - 1)
	exit(0)
print(a * (a + 1) // 2 + m - 1)


(n, v) = map(int, input().split())
n = n - 1
n -= v
i = 2
s = 0
if n > 0:
	s += v
else:
	s += n + v
while n > 0:
	n -= 1
	s += i
	i += 1
else:
	print(s)


(n, v) = [int(x) for x in input().split()]
result = 0
if n - 1 <= v:
	print(n - 1)
else:
	result = v
	for i in range(2, n + 1):
		if n - i >= v:
			result += i
	print(result)


(n, v) = map(int, input().split())
l_f = n - v
if l_f < 2:
	print(n - 1)
else:
	n = n - v
	print(v - 1 + n * (n + 1) // 2)


l = list(map(int, input().split()))
n = l[0]
v = l[1]
if v >= n - 1:
	print(n - 1)
else:
	count = v
	for i in range(2, n - v + 1):
		count += i
	print(count)


(N, V) = map(int, input().split())
if V >= N:
	print(N - 1)
else:
	chalnaha = N - 1
	chalsakteha = V
	cost = V
	i = 2
	while chalnaha > chalsakteha:
		chalnaha -= 1
		cost += i * 1
		i += 1
	print(cost)


(n, k) = map(int, input().split())
if n - 1 <= k:
	print(n - 1)
else:
	cnt = k
	ans = k
	i = 2
	while cnt != n - 1:
		ans = ans + i
		cnt += 1
		i += 1
	print(ans)


(n, v) = map(int, input().split())
if v >= n or v == n - 1:
	print(n - 1)
else:
	l = n - v
	amount = (1 + l) * (n - v) // 2
	print(amount + (v - 1))


from itertools import combinations, permutations
from collections import defaultdict
import math
import sys
import os

def solution(n, v):
	ans = min(n - 1, v)
	for i in range(2, n + 1 - ans):
		ans += i
	return ans

def main():
	(n, v) = map(int, input().strip().split())
	print(solution(n, v))
main()


(n, c) = list(map(int, input().split()))
result = 0
if c >= n - 1:
	print(n - 1)
else:
	fuel_needed = n - 1 - c
	result += c
	for i in range(2, n + 1):
		if fuel_needed == 0:
			break
		fuel_needed -= 1
		result += i
	print(result)


(n, v) = list(map(int, input().rstrip().split()))
preis = 0
if v >= n:
	preis = n - 1
else:
	preis += v
	i = 1
	while v < n - 1:
		v += 1
		i += 1
		preis += i
print(preis)


import sys
array = input().split(' ')
for (i, val) in enumerate(array):
	array[i] = int(val)
kilos = array[0] - 1
tank = array[1]
fill = kilos - tank
cost = tank
if tank >= kilos:
	print(kilos)
else:
	count = 0
	while count < fill:
		cost += count + 2
		count += 1
	print(cost)


(n, v) = map(int, input().split())
req = n - 1
if req <= v:
	print(req)
else:
	total = v
	remaining = req - v
	for x in range(remaining):
		total += 2 + x
	print(total)


(a, b) = map(int, input().split())
s = min(a - 1, b)
for i in range(max(a - 1, b) - b):
	s = s + i + 2
print(s)


(n, m) = map(int, input().split())
if n > m:
	print(sum([i if i != 1 else m for i in range(1, n - m + 1)]))
else:
	print(n - 1)


line = input()
(n, v) = map(int, line.strip().split())
a = v
for i in range(2, n - v + 1):
	a += i
if v >= n:
	a = n - 1
print(a)


import math as mt
(n, v) = map(int, input().split())
ans = v - 1
if n - 1 < v:
	print(n - 1)
else:
	for i in range(1, n - v + 1):
		ans += i
	print(ans)


(n, v) = [int(x) for x in input().split()]
if v >= n - 1:
	print(n - 1)
else:
	a = n - v
	ans = v
	for i in range(2, a + 1):
		ans += i
	print(ans)


(n, v) = map(int, input().strip().split())
distance_left = n - 1
capacity_left = v
money_used = 0
for i in range(1, n):
	fuel_bought_at_i = min(distance_left - (v - capacity_left), capacity_left)
	money_used += fuel_bought_at_i * i
	capacity_left -= fuel_bought_at_i
	capacity_left += 1
	distance_left -= 1
print(money_used)


import math
(n, v) = map(int, input().split())
(i, pre, cost) = (1, 0, 0)
while i < n:
	if n - i > pre:
		if n - i <= v:
			cost += i * (n - i - pre)
			break
		else:
			cost += i * (v - pre)
			pre = v
	i += 1
	pre -= 1
print(cost)


(n, v) = [int(item) for item in input().split()]
x = 0
c = 0
for i in range(1, n):
	if x < n - i:
		c += i * min(n - i, v - x)
		x += min(n - i, v - x)
	x -= 1
print(c)


from sys import stdin
(n, v) = map(int, stdin.readline().split())
if n <= v:
	cost = n - 1
else:
	cost = v
	for i in range(2, n - v + 1):
		cost += i
print(cost)


(n, v) = list(map(int, input().split()))
if v >= n - 1:
	print(n - 1)
else:
	p = n - 1
	x = v
	for k in range(2, 2 + (n - 1 - v)):
		x += k
	print(x)


(n, v) = map(int, input().split())
r = 0
num = 0
if n - 1 <= v:
	print(n - 1)
else:
	r = v - 1
	num = v
	for i in range(2, n + 1):
		if n - i <= r:
			print(num)
			exit()
		else:
			num += i


st = input().split(' ')
n = int(st[0])
v = int(st[1])
if n < v + 1:
	print(n - 1)
else:
	temp = 0
	temp += v
	i = 1
	while n - i > v:
		i += 1
		temp += i
	print(temp)


(n, k) = map(int, input().split())
ans = k
if n - k == 1:
	print(k)
elif n - k == 0:
	print(k - 1)
elif n < k:
	print(n - 1)
elif n > k:
	for i in range(2, n - k + 1):
		ans += i
	print(ans)


_ = input()
(n, v) = _.split()
(n, v) = (int(n), int(v))
money = 0
round = 2
cap = min(n - 1, v)
money = money + cap
while round < n:
	cap = cap - 1
	if round + cap < n:
		money = money + round
		cap = cap + 1
	round = round + 1
print(money)


(n, v) = list(map(int, input().split(' ')))
v = min(v, n)
print(int((n - v + 1) * (n - v) / 2 + v - 1))


(n, capacity) = map(int, list(input().split()))
cur_v = 1
amount = 0
for i in range(1, n + 1):
	cur_v -= 1
	if cur_v < n - i:
		fuel = min(n - i, capacity - cur_v)
		amount += fuel * i
		cur_v += fuel
print(amount)


from sys import stdin, stdout

def inp():
	return stdin.readline()

def minp():
	return map(int, stdin.readline().rstrip().split())

def linp():
	return list(minp())

def main():
	(n, v) = minp()
	np = n - 1
	(cost, p) = (0, 0)
	nn = int((np - 1) / v)
	if np <= v:
		print(np)
	else:
		cost += v
		d = np - v
		e = 2
		for i in range(d):
			cost += e
			e += 1
		print(cost)
main()


arr_in = input().split()
(n, v) = (int(arr_in[0]), int(arr_in[1]))
if v >= n - 1:
	print(n - 1)
else:
	print(int((2 * 2 + n - 2 - v) / 2 * (n - 1 - v) + v))


def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]
(n, v) = read_ints()

def solve(n: int, v: int) -> int:
	if n - 1 < v:
		return n - 1
	if n == v:
		return v
	res = v - 1
	for i in range(1, n - v + 1):
		res += i
	return res
print(solve(n, v))


(n, v) = map(int, input().split())
curr_litre = 0
req_litre = n - 1
cost = 0
for i in range(1, n):
	to_fill = min(v - curr_litre, req_litre)
	curr_litre += to_fill
	curr_litre += -1
	cost += to_fill * i
	req_litre -= to_fill
print(cost)


from sys import stdin
input = stdin.readline
(n, v) = map(int, input().split())
dp = [0 for i in range(n)]
if v >= n:
	v = n - 1
curL = v
dp[0] = v
for i in range(1, n):
	curL -= 1
	if curL < n - (i + 1):
		c = v - curL
		curL = v
		dp[i] = c * (i + 1) + dp[i - 1]
	else:
		dp[i] = dp[i - 1]
print(dp[n - 1])


(c, t) = list(map(int, input().split()))
road = int(c - 1)
money = t
if t < road:
	for i in range(2, c + 1):
		if t == road:
			break
		elif t < road:
			money += i
			road -= 1
	print(money)
elif t >= road:
	print(road)


(n, v) = map(int, input().split())
dist = n - 1
amt = v
if amt >= dist:
	print(dist)
else:
	i = 2
	while dist > v:
		amt += i
		dist -= 1
		i += 1
	print(amt)


a = list(map(int, input().split()))
n = a[0]
v = a[1]
c = 0
l = 0
for i in range(1, n):
	if n - i <= l:
		break
	x = l
	if n - i < v:
		l = n - i
	else:
		l = v
	c = c + i * (l - x)
	l = l - 1
print(c)


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5:
	from math import gcd
else:
	from fractions import gcd
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def round(x):
	return int((x * 2 + 1) // 2)

def fermat(x, y, MOD):
	return x * pow(y, MOD - 2, MOD) % MOD

def lcm(x, y):
	return x * y // gcd(x, y)

def lcm_list(nums):
	return reduce(lcm, nums, 1)

def gcd_list(nums):
	return reduce(gcd, nums, nums[0])

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
(N, V) = MAP()
tank = 0
ans = 0
for i in range(1, N):
	if N - i > tank:
		need = min(N - i, V - tank)
		tank += need
		ans += need * i
	tank -= 1
print(ans)


(n, v) = (int(x) for x in input().split())
costs = [1] * v + list(range(2, n))
print(sum(costs[:n - 1]))


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	c = v
	i = 2
	money = v
	while c != n - 1:
		money = money + i * 1
		i = i + 1
		c = c + 1
	print(money)


(n, v) = input().split()
n = int(n)
v = int(v)
cur_lit = 0
req_lit = n - 1
money = 0
for i in range(1, n):
	charge = min(v - cur_lit, req_lit)
	cur_lit = cur_lit + charge
	cur_lit = cur_lit - 1
	money = money + charge * i
	req_lit = req_lit - charge
print(money)


(n, v) = map(int, input().split())
need_benzin = n - v - 1
if v < n:
	money = v
else:
	money = n - 1
for i in range(0, need_benzin):
	money += i + 2
print(money)


inp = input()
(n, k) = inp.split()
n = int(n)
k = int(k)
volume_filled = 0
cost = 0
for i in range(1, n + 1):
	diff = k - volume_filled
	if diff > n - i - volume_filled:
		cost = cost + (n - i - volume_filled) * i
		volume_filled = n - i
	else:
		cost = cost + diff * i
		volume_filled = k
	volume_filled = volume_filled - 1
print(cost)


INF = float('inf')
(n, v) = map(int, input().split())
dp = [INF] * (n + 1)
dp[1] = v
for i in range(2, n + 1 - v):
	for x in range(1, v + 1):
		if i - x >= 0:
			dp[i] = dp[i - 1] + i
if n > v:
	print(dp[n - v])
else:
	print(n - 1)


(n, v) = [int(v) for v in input().split()]
ans = 0
curr = 0
for i in range(1, n + 1):
	if curr >= n - i:
		break
	inc = min(v - curr, n - 1 - curr)
	ans += i * inc
	curr += inc
	curr -= 1
print(ans)


(n, v) = map(int, input().split())
petrol_needed = n - 1
needs_to_be_filled_at = n - v
cost = 0
if n <= v:
	cost = n - 1
else:
	cost = v
	for i in range(2, needs_to_be_filled_at + 1):
		cost = cost + i
print(cost)


x = input()
xx = x.split()
n = int(xx[0])
v = int(xx[1])
if v >= n - 1:
	print(n - 1)
else:
	f = v - 1 + (n - v) * (n - v + 1) / 2
	print(int(f))


import math
(n, v) = map(int, input().split(' '))
cost = 0
if v >= n:
	cost = n - 1
else:
	cost = v + (n - v - 1) * (n - v + 2) / 2
print(int(cost))


(n, m) = map(int, input().split())
if n <= m + 1:
	p = n - 1
else:
	p = c = m
	for i in range(2, n + 1):
		c -= 1
		if n - i <= c:
			break
		c += 1
		p += i
print(p)


def fuel(n, v):
	cost = v
	sum = v
	x = n - v
	if x <= 0:
		return n - 1
	for i in range(2, x + 1):
		cost += i
	return cost
(m, n) = map(int, input().split())
print(fuel(m, n))


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 10 ** 9 + 7

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

def count(n):
	return n * (n + 1) // 2

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, v) = get_ints()
if v >= n - 1:
	print(n - 1)
	exit()
cost = v
for i in range(2, n + 1):
	cost += i
	if v >= n - i:
		break
print(cost)


(cities, tank) = [int(i) for i in input().strip().split()]
c_fuel = 0
ans = 0
for i in range(1, cities + 1):
	if c_fuel >= cities - i:
		break
	elif cities - i - tank > 0:
		ans += i * (tank - c_fuel)
		c_fuel = tank
	else:
		ans += i * (cities - i - c_fuel)
		break
	c_fuel -= 1
print(ans)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	price = v
	n = n - 1
	i = 2
	for j in range(n - v):
		price += i
		i += 1
	print(price)


(n, v) = list(map(int, input().split()))
a = 2
c = v
if v >= n - 1:
	print(v - (v - n + 1))
	exit()
while a < n - (v - 1):
	c += a
	a += 1
print(c)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	x = v
	i = 2
	q = v * 1
	y = x
	while i <= n and y < n - 1:
		x = x - 1
		p = min(v - x, min(v, n - 1 - x))
		x += p
		q += i * p
		y += p
		i += 1
	print(q)


(n, v) = list(map(int, input().split()))
litres = 0
price = 0
litres1 = 0
fill = 0
chuj = 1
if n - 1 < v:
	print(n - 1)
else:
	price = v
	for i in range(2, n):
		if n - i < v:
			print(price)
			chuj = 0
			break
		price = price + i
	if chuj == 1:
		print(price)


def main():
	(n, v) = (int(x) for x in input().split())
	print(solver(n, v))

def solver(n, v):
	city = 1
	gas = 0
	money = 0
	for city in range(1, n):
		if n - city <= gas:
			break
		elif n - city <= v:
			money += (n - city - gas) * city
			break
		else:
			money += city * (v - gas)
			gas = v - 1
	return money
main()


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
if n <= k:
	print(n - 1)
else:
	ans = k - 1
	nn = n - k
	ans += nn * (nn + 1) // 2
	print(ans)


(n, v) = map(int, input().split())
fuel = n - v - 1
if fuel < 0:
	print(n - 1)
elif fuel == 0:
	print(v)
else:
	price = v + (fuel + 3) * fuel // 2
	print(price)


(n, v) = map(int, input().split(' '))
c = min(n - 1, v)
i = 2
tot = 1
while i <= n - v:
	c += i
	i += 1
print(c)


(n, v) = map(int, input().split())
pet = n - 1
price = 0
if pet > v:
	petrol = v
	price = v
	for i in range(2, n):
		petrol = petrol - 1
		pet = pet - 1
		if petrol < pet:
			price = price + i
			petrol = petrol + 1
		if petrol == pet:
			break
else:
	price = pet
print(price)


(n, v) = list(map(int, input().split(' ')))
sum_cost = 0
if n <= v:
	print(n - 1)
else:
	sum_cost = v
	to_end = n - 1
	cur_city = 1
	while to_end > v:
		cur_city += 1
		sum_cost += cur_city
		to_end -= 1
	print(sum_cost)


(n, v) = map(int, input().split())
if v >= n:
	print(n - 1)
else:
	print(int(v + 0.5 * (2 + n - v) * (n - v - 1)))


n = list(map(int, input().split()))
if n[1] >= n[0] - 1:
	print(n[0] - 1)
else:
	w = n[1]
	for i in range(2, n[0] - n[1] + 1):
		w = w + i
	print(w)


vvod = input()
(n, v) = vvod.split()
n = int(n)
v = int(v)
if v >= n - 1:
	s = n - 1
	print(s)
else:
	x = n - 1 - v
	i = 1
	s = 0
	while i <= x:
		s = i + 1 + s
		i = i + 1
	s = v + s
	print(s)


(n, v) = map(int, input().split())
i = 0
j = 1
x = 0
if v < n - 1:
	x = x + v
	i = i + v
	j = 2
	while x < n - 1:
		i = i + j
		x = x + 1
		j = j + 1
else:
	i = n - 1
print(i)


(n, v) = map(int, input().split())
inf = float('inf')
dp = [[inf] * (v + 1) for _ in [0] * n]
dp[0] = list(range(v + 1))
for i in range(1, n):
	for f in range(v + 1):
		dp[i][f] = min([dp[i - 1][f + 1 - j] + (i + 1) * j for j in range(f == v, f + 1)])
print(min(dp[-1]))


(n, v) = [int(s) for s in input().split()]
sum_ = v
i = v + 1
if n - 1 - v <= 0:
	print(n - 1)
else:
	print(sum_ + (n - v) * (n - v + 1) // 2 - 1)


(n, v) = map(int, input().split())
cost = 0
if v >= n - 1:
	print(n - 1)
else:
	k = n - 1 - v
	print(k * (3 + k) // 2 + v)


(n, v) = map(int, input().split())
km = n - 1
res = 0
if km <= v:
	print(km)
else:
	y = km - v
	sf = (y + 1) * (y + 2) // 2
	sf += v - 1
	print(sf)


(n, v) = map(int, input().split())
cetak = v
har = 2
jarak = v
if v >= n - 1:
	print(n - 1)
else:
	while jarak < n - 1:
		jarak += 1
		cetak += har
		har += 1
	print(cetak)


NV = list(map(int, input().split()))
Cost = 0
ActualFuel = 0
Destiny = NV[0]
TankSize = NV[1]
ActualPosition = 1
if TankSize < Destiny:
	ActualFuel = TankSize
	Cost = TankSize
	while True:
		if ActualPosition + ActualFuel >= Destiny:
			break
		else:
			if ActualPosition + ActualFuel - 1 < Destiny:
				ActualFuel += 1
			ActualPosition += 1
			Cost = Cost + ActualPosition
		ActualFuel -= 1
	print(Cost)
else:
	Cost = Destiny - 1
	print(Cost)


(n, v) = map(int, input().split())

def add():
	if n - 1 <= v:
		print(n - 1)
		return 0
	res = v - 1
	for i in range(1, n - v + 1):
		res += i
	print(res)
m = add()


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	sum = v
	status = v
	i = 2
	while i < n:
		status = status - 1
		if n - i > status:
			status = status + 1
			sum = sum + i
		i = i + 1
	print(sum)


(n, v) = map(int, input().split())
print((v + (n - v) * (n - v + 1) // 2, n)[v > n - 1] - 1)


(n, v) = map(int, input().split())
b = 0
ans = 0
sss = 0
for i in range(1, n + 1):
	while b < v:
		if sss == n - 1:
			break
		sss += 1
		ans += i
		b += 1
	b -= 1
print(ans)


(n, v) = list(map(int, input().split()))
f = lambda x: x * (x + 1) // 2
print(min(n - 1, v) + f(n - min(n - 1, v)) - 1)


nv = list(map(int, input().split()))
currient_gas = 0
total_cost = 0
for i in range(1, nv[0]):
	if currient_gas < nv[0] - i:
		total_cost += (min(nv[1], nv[0] - 1) - currient_gas) * i
		currient_gas = min(nv[1], nv[0] - 1)
	currient_gas -= 1
print(total_cost)


from sys import stdin, stdout
import bisect
import math
from collections import deque
mod = 10 ** 9 + 7

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, v) = mp()
	cost = 0
	if n <= v:
		print(n - 1)
		return
	if n == v + 1:
		pr(v)
		return
	cost = v - 1
	for i in range(1, n - v + 1):
		cost += i
	pr(cost)
for _ in range(1):
	solve()


(n, v) = list(map(int, input().split()))
result = 0
cur_v = 0
for i in range(1, n):
	rest = n - i
	add = min(v - cur_v, rest - cur_v)
	result += add * i
	cur_v += add - 1
print(result)


def chepestTrip():
	nV = str(input())
	splittedNv = nV.split(' ')
	n = int(splittedNv[0])
	v = int(splittedNv[1])
	if v >= n:
		return n - 1
	fuel = v
	moneyFuel = v
	for i in range(2, n):
		fuel -= 1
		if n - i - fuel == 0:
			break
		moneyFuel += i
		fuel += 1
		if n - i - fuel == 0:
			break
	return moneyFuel
res = chepestTrip()
print(res)


(n, v) = input().split(' ')
(n, v) = (int(n), int(v))
if n > v:
	print(int((n - v) * (n - v + 1) / 2 + v - 1))
else:
	print(n - 1)


def ia():
	return list(map(int, input().split()))

def ca():
	return input().split()

def ii():
	return int(input())
(n, k) = ia()
c = 0
cap = 0
for i in range(1, n + 1):
	x = min(n - i - cap, k - cap)
	cap += x
	c += x * i
	cap -= 1
print(c)


(n, v) = map(int, input().split())
a = range(2, n + 1)
print(v + sum(a[:-v]) if v < len(a) else n - 1)


f = lambda : map(int, input().split())
(n, v) = f()
if n - 1 < v:
	print(n - 1)
else:
	(i, ans) = (1, v)
	while v < n - i:
		i += 1
		ans += i
	print(ans)


TN = 1

def solution():
	(n, v) = map(int, input().split())
	if v >= n - 1:
		print(n - 1)
	else:
		print(v + int((2 + n - v) / 2 * (n - v - 1)))
while TN != 0:
	solution()
	TN -= 1


(n, v) = map(int, input().split())
sumd = v
km = 0
if v >= n - 1:
	print(n - 1)
else:
	for i in range(2, n):
		if km + v == n - 1:
			break
		sumd = sumd + i
		km += 1
	print(sumd)


(n, v) = [int(i) for i in input().split()]
t = n - 1
if v < n - 1:
	c = v
	k = v
	for i in range(2, n):
		c += i
		t -= 1
		if k >= t:
			break
else:
	c = n - 1
print(c)


(n, v) = map(int, input().split())
if n - 1 < v:
	print(n - 1)
	exit()
count = 0
for i in range(1, n - v + 1):
	count += i
print(count + v - 1)


def main():
	tmp = [int(i) for i in input().split()]
	N = tmp[0]
	vm = tmp[1]
	cost = 0
	if N <= vm:
		return N - 1
	adj = range(2, N + 1)
	v = vm
	cost += vm
	for n in adj:
		v -= 1
		while v < vm and v < N - n:
			cost += n
			v += 1
	return cost
print(main())


(n, v) = map(int, input().split())
x = min(n - 1, v)
if x < n - 1:
	x = v - 1
	for i in range(1, n - v + 1):
		x += i
print(x)


(n, cap) = map(int, input().split())
if cap >= n:
	print(n - 1)
else:
	j = n - cap
	s = j * (j + 1) // 2 + cap - 1
	print(s)


(n, k) = [int(i) for i in input().split()]
res = min(k, n - 1)
n -= k
if n > 0:
	res += n * (n + 1) // 2 - 1
print(res)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	e = (n - v - 1) * (n + 2 - v) // 2
	print(e + v)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	rem = n - 1 - v
	a = (rem + 1) * (rem + 2) // 2 - 1
	print(v + a)


(cities, fuel_cap) = input().split()
(cities, fuel_cap) = (int(cities), int(fuel_cap))

def calc(cities, fuel_cap):
	if fuel_cap >= cities - 1:
		return cities - 1
	km_to_cover = cities - 1
	price = tank = fuel_cap
	for i in range(2, cities + 1):
		km_to_cover -= 1
		if tank - 1 >= km_to_cover:
			return price
		price += i
	return price
print(calc(cities, fuel_cap))


(e, f) = (0, 0)
(n, v) = map(int, input().split())
g = e + f
num = max(n - v, 0)
fuel = min(v, n) + int(num * (num + 1) // 2) - 1
print(fuel)


(n, v) = [int(x) for x in input().split()]
if v >= n:
	print(n - 1)
	exit()
cost = v
for i in range(1, n - v):
	cost += i + 1
print(cost)


valor = input()
valor1 = valor.split()
n = int(valor1[0])
v = int(valor1[1])
g = v
b = v
if v < n - 1:
	for i in range(n - 1):
		if g != n - 1:
			g = g + 1
			b = b + (2 + i)
	print(b)
elif v > n - 1:
	print(n - 1)
else:
	print(v)


def main():
	(n, v) = map(int, input().split())
	n -= 1
	if v >= n:
		print(n)
		return
	p = (1 + n - v) * (2 + n - v) // 2 + v - 1
	print(p)
main()


from sys import stdin, stdout
(n, v) = [int(x) for x in stdin.readline().rstrip().split()]
if v < n:
	ans = v - 1 + (n - v) * (n - v + 1) // 2
else:
	ans = n - 1
print(ans)


(n, v) = map(int, input().split())
res = v
if n - v > 1:
	res = (n - v) * (n - v + 1) // 2 + v - 1
if v >= n:
	res = n - 1
print(res)


import sys
import math
import time
(n, v) = [int(j) for j in input().split()]
cost = min(n - 1, v)
fuel = min(n - 1, v)
for i in range(n):
	dist = n - i - 1
	if fuel == dist:
		break
	else:
		extra = min(dist, v - fuel)
		fuel += extra
		cost += (i + 1) * extra
	fuel -= 1
print(cost)


from sys import stdin, exit
input = stdin.readline
(N, V) = map(int, input().split())
if V > N - 1:
	print(N - 1)
	exit(0)
else:
	print(N - 1 + (N - V) * (N - 1 - V) // 2)


(n, m) = map(int, input().split())
base = min(n - 1, m)
tt = n - 1 - m
i = 2
while tt > 0:
	base += i
	i += 1
	tt -= 1
print(base)


(a, b) = map(int, input().split())
a -= 1
c = a - b + 1
print([a, -1 + b + c * (c + 1) // 2][b < a])


from sys import stdin
input = stdin.readline
(n, v) = list(map(int, input().split()))
v = min(n, v)
print(int(v + (2 + n - v) * (n - v - 1) / 2))


def f():
	(n, v) = map(int, input().split())
	l = n - v
	sum = 0
	for i in range(2, l + 1):
		sum = sum + i
	sum = sum + v
	if v >= n:
		print(n - 1)
	else:
		print(sum)
f()


(x, y) = map(int, input().split())
if x <= y:
	print(x - 1)
else:
	c = y
	i = 2
	o = x - 1 - y
	while o:
		c += i
		i += 1
		o -= 1
	print(c)


import sys
from sys import stdin, stdout
sys.setrecursionlimit(10000)
(n, v) = input().strip().split(' ')
(n, v) = (int(n), int(v))
total_cost = min(v, n - 1)
cost = 2
litres_needed = n - 1 - total_cost
for i in range(litres_needed):
	total_cost += cost
	cost += 1
print(total_cost)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	(n, v) = MI()
	x = v
	ans = 0
	if n - 1 <= v:
		ans = n - 1
	else:
		i = 1
		ans += x
		while n - 1 != 0 or x != n - 1:
			x -= 1
			i += 1
			n = n - 1
			if x != n - 1:
				ans += i
				x += 1
			else:
				break
	pf(str(ans))
main()


x = input().split()
n = int(x[0])
k = int(x[1])
if n - 1 <= k:
	print(n - 1)
else:
	tot = k
	cur = 2
	while n - 1 > k:
		tot += cur
		cur += 1
		n -= 1
	print(tot)


(c, v) = map(int, input().split())
c -= 1
if c <= v:
	print(c)
else:
	d = v
	p = 2
	an = v
	while d < c:
		d += 1
		an += p
		p += 1
	print(an)


(n, v) = map(int, input().split())
if v >= n:
	print(n - 1)
else:
	out = v
	n -= v
	while n > 1:
		out += n
		n -= 1
	print(out)


(n, k) = map(int, input().split())
z = n - k - 1
if n - k <= 0:
	print(n - 1)
else:
	print(k + z * (z + 1) // 2 + z)


(n, v) = [int(i) for i in input().split()]
need = n - 1
if v >= n - 1:
	print(n - 1)
else:
	p = n - v
	s = p * (p + 1) // 2
	s = s + v
	s = s - 1
	print(s)


(n, v) = map(int, input().split())
if n - 1 == v:
	print(v)
elif v > n:
	print(n - 1)
elif n == v:
	print(n - 1)
else:
	price = 0
	tank = 0
	for i in range(1, n):
		if n - i > tank:
			refueled = v - tank
			tank += refueled
			price += refueled * i
		tank -= 1
	print(price)


def main():
	(n, v) = map(int, input().split())
	start = 1
	dist = n - 1
	if v >= n:
		print(n - 1)
		return
	i = 1
	cost = i * min(v, n - 1)
	for i in range(2, n + 1):
		if n + 1 - i == v:
			break
		else:
			cost += i
	print(cost)
main()


(num_cities, deposit) = map(int, input().split())
num_kilometers = num_cities - 1
if num_kilometers <= deposit:
	print(num_kilometers)
else:
	solution = deposit
	num_kilometers -= deposit - 1
	print(int(solution - 1 + num_kilometers * (num_kilometers + 1) / 2))


(n, v) = map(int, input().split())
cost = 0
contain = 1
for i in range(1, n + 1):
	contain -= 1
	need = n - i
	if need > contain:
		space = v - contain
		buy = min(space, need)
		contain += buy
		cost += buy * i
print(cost)


(n, v) = map(int, input().split())
cost = min(v, n - 1)
f = min(v, n - 1)
for i in range(2, n + 1):
	f -= 1
	if f < n - i:
		t = f
		f += min(v, n - i)
		f = min(v, f)
		cost += abs(t - f) * i
print(cost)


nv = list(map(int, input().split()))
n = nv[0]
v = nv[1]
if n - 1 > v:
	c = v
else:
	c = n - 1
for i in range(2, n - v + 1):
	c = c + i
print(c)


(n, v) = map(int, input().split())
dist = n - 1
cost = 0
i = 1
fuel = 0
while True:
	if i == n:
		break
	if fuel >= dist:
		break
	cost += i * min(v - fuel, dist)
	fuel = v
	i += 1
	fuel -= 1
	dist -= 1
print(cost)


(n, v) = map(int, input().split())
benz = 0
ans = 0
for i in range(1, n + 1):
	if benz < v and n - i > benz:
		if n - i >= v:
			ans += (v - benz) * i
			benz = v
		else:
			ans += (n - i) * i
			benz += n - i
	benz -= 1
print(ans)


(n, v) = [int(i) for i in input().split()]
cost = 0
curr = 0
for i in range(1, n + 1):
	if i + curr >= n:
		break
	else:
		add = min(v - curr, n - i)
		cost += add * i
		curr += add
	curr -= 1
print(cost)


import os
import sys
from io import BytesIO, IOBase

def solve():
	(n, v) = list(map(int, input().split()))
	if n - 1 > v:
		m = v
	else:
		m = n - 1
		return m
	for i in range(2, n - v + 1):
		m = m + i
	return m

def main():
	print(solve())
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(a, b) = map(int, input().split())
a -= 1
hey = a - b
ans = min(a, b)
hi = 2
while hey > 0 and a > b:
	ans += hi
	hi += 1
	hey -= 1
print(ans)


(n, v) = list(map(int, input().strip().split()))
remaining_dist = n - 1
adding = min(remaining_dist, v)
cost = adding
remaining_dist -= adding
i = 2
while remaining_dist > 0:
	cost += i
	i += 1
	remaining_dist -= 1
print(cost)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, v) = M()
if v >= n - 1:
	print(n - 1)
else:
	x = n - v
	print(x * (x + 1) // 2 + v - 1)


list = [int(x) for x in input().split()]
dist = list[0]
tank = list[1]

def pol():
	if dist - 1 <= tank:
		return dist - 1
	else:
		res = tank - 1
		for i in range(1, dist - tank + 1):
			res += i
		return res
print(pol())


import math
import sys
(n, v) = map(int, input().split())
if n - 1 <= v:
	cost = n - 1
else:
	b = n - v
	cost = b * (b + 1) // 2 + v - 1
print(cost)


(n, k) = map(int, input().split())
if n - 1 <= k:
	print(n - 1)
else:
	cnt = k - 1
	for i in range(1, n - k + 1):
		cnt += i
	print(cnt)


(n, m) = map(int, input().split())
m = min(m, n - 1)
k = n - m
print(k * (k + 1) // 2 + m - 1)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(min(v, n - 1))
else:
	sum1 = v
	for i in range(2, n - v + 1):
		sum1 += i
	print(sum1)


def Maxmoney(n, v):
	if v > n - 1:
		return n - 1
	else:
		last_stop = n - v
		total = v
		for i in range(2, last_stop + 1):
			total += i
		return total
line = input().split()
cities = int(line[0])
tank = int(line[1])
print(Maxmoney(cities, tank))


def main() -> None:
	(n, v) = map(int, input().split())
	fuel = 0
	money = 0
	for i in range(1, n):
		if fuel < n - i:
			if v > n - i:
				money += (n - i - fuel) * i
				fuel += n - i - fuel
			else:
				money += (v - fuel) * i
				fuel += v - fuel
		fuel -= 1
	print(money)
main()


(n, v) = map(int, input().split())
tank = 0
money = 0
for i in range(1, n + 1):
	if tank < n - i:
		litres = min(n - i, v - tank)
		tank += litres
		money += i * litres
	tank -= 1
print(money)


import sys
(n, v) = map(int, input().split())
total_needed = n - 1
if total_needed <= v:
	print(total_needed)
	sys.exit()
excess = total_needed - v + 1
cost = v + excess * (excess + 1) // 2 - 1
print(cost)


(n, v) = map(int, input().split())
ans = n - 1
if v < ans:
	ans += (ans - v) * (ans - v + 1) >> 1
print(ans)


from sys import stdin, stdout
(n, v) = [int(x) for x in stdin.readline().split()]
if n > v:
	s = v
	for i in range(2, n + 1):
		a = n - i
		if a > v:
			s += i
		elif a == v:
			s += i
			break
		elif a < v:
			break
	print(s)
else:
	print(n - 1)


a = list(map(int, input().split()))
n = a[0]
v = a[1]
if n < v:
	print(n - 1)
else:
	ans = v
	ans = ans + (n - v - 1) * (n - v + 2) // 2
	print(ans)


import math

def s():
	(n, v) = [int(x) for x in input().split(' ')]
	ans = min(n - 1, v)
	stop = 1
	fuel = min(n - 1, v)
	for i in range(2, n):
		fuel -= 1
		stop += 1
		if n - i >= v:
			ans += (v - fuel) * i
			fuel += v - fuel
	return ans
ans = s()
print(ans)


import math
(n, v) = map(int, input().split())
tc = n - 1
p = 0
if tc <= v:
	p = tc
else:
	p = v
	for i in range(2, n - v + 1):
		p += i
print(p)


n = input()
l = list(map(int, n.split(' ')))
city = l[0] - 1
cost = l[1]
i = 1
if city < cost:
	cost = city
else:
	while city != l[1] or city < l[1]:
		i = i + 1
		cost = cost + i
		city = city - 1
print(cost)


(n, m) = list(map(int, input().split()))
if n < m:
	print(n - 1)
else:
	s = (n - m) * (n - m + 1)
	s = s // 2
	s = s - 1 + m
	print(s)


(n, v) = map(int, input().split())
if v > n or v == n:
	print(n - 1)
else:
	t = n - 1
	t1 = t - v
	s = (t1 + 1) * (t1 + 2) // 2
	s1 = v + s - 1
	print(s1)


(n, v) = map(int, input().split())
distance = n - 1
if v >= distance:
	print(distance)
else:
	cost = v
	for i in range(2, distance - v + 2):
		cost += i
	print(cost)


a = str(input())
b = ['', '']
k = -1
for i in range(0, 2):
	k += 1
	while k <= len(a) - 1 and a[k] != ' ':
		b[i] += a[k]
		k += 1
n = int(b[0])
v = int(b[1])
q = v
k = n - v
if k == 0 or k < 0:
	print(n - 1)
else:
	for i in range(2, k + 1):
		q += i
	print(q)


(n, v) = map(int, input().split())
C = list(([-1] * (v + 1) for i in range(n)))
for i in range(n):
	for m in range(v + 1):
		if i == 0:
			C[i][m] = m
		else:
			C[i][m] = min((C[i - 1][m + 1 - j] + j * (i + 1) for j in range(0 if m < v else 1, m + 1)))
print(C[n - 1][0])


(n, v) = input().split()
(n, v) = [int(n), int(v)]
if 100 < n < 2 or 100 < v < 1:
	exit()
price = v
cur_fuel = v
if cur_fuel + 1 >= n:
	print(n - 1)
	exit()
for cur_city in range(2, n + 1):
	cur_fuel -= 1
	if cur_fuel != n - cur_city:
		cur_fuel += 1
		price += cur_city
	else:
		break
print(price)


import sys
(n, v) = map(int, input().split())
if n - 1 <= v:
	res = n - 1
else:
	x = n - v + 1
	res = x * (x - 1) // 2
	res += v - 1
print(res)


def calc(v, c):
	if c <= v:
		r = c - 1
	else:
		r = v
		for i in range(c - v - 1):
			r += i + 2
	print(r)

def main():
	try:
		get = [int(x) for x in input().split(' ')]
		c = get[0]
		v = get[1]
		calc(v, c)
		main()
	except:
		print()
main()


from sys import stdin
(n, v) = map(int, stdin.readline().split())
cur_litres = 0
req_litres = n - 1
cost = 0
for i in range(1, n):
	litres_to_fill = min(v - cur_litres, req_litres)
	cost += litres_to_fill * i
	cur_litres += litres_to_fill
	cur_litres -= 1
	req_litres -= litres_to_fill
print(cost)


X = list(map(int, input().split()))
Tank = X[0] - 1 if X[0] <= X[1] else X[1]
Difference = X[0] - X[1]
Tank += Difference * (Difference + 1) // 2 - 1 if Difference > 0 else 0
print(Tank)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, u) = LI()
	k = n - 1
	if k <= u:
		return k
	return u + (k - u + 3) * (k - u) // 2
print(main())


(n, v) = map(int, input().split())
cur = 0
ans = 0
for i in range(n):
	need = max(min(n - 1 - i - cur, v - cur), 0)
	cur += need
	ans += (i + 1) * need
	cur -= 1
print(ans)


(n, v) = [int(i) for i in input().split(' ')]

def helper(n, v):
	if v == 1:
		return n * (n - 1) // 2
	if v >= n - 1:
		return n - 1
	else:
		return v - 1 + (1 + (n - v)) * (n - v) // 2
print(helper(n, v))


p = input().split()
node = int(p[0])
m = int(p[1])
if m >= node:
	print(node - 1)
else:
	price = node - 1 - m
	for i in range(2, 2 + price):
		m += i
	print(m)


(n, v) = map(int, input().split())
if v > n or v == n:
	print(n - 1)
else:
	tank = v
	amount = v
	for i in range(2, n + 1):
		tank = tank - 1
		if tank == n - i:
			break
		else:
			amount += (v - tank) * i
			tank = v
	print(amount)


import sys
import itertools
import math
import collections
from collections import Counter

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
(n, v) = mi()
t = n - v
print(v + t * (t + 1) // 2 - 1) if t > 0 else print(n - 1)


(a, b) = map(int, input().split())
t = a - 1 - b
s = b
if a <= b:
	print(a - 1)
else:
	for i in range(t):
		s = s + i + 2
	print(s)


(n, v) = map(int, input().split())
roads = n - 1 - v
if roads >= 0:
	res = v
	cur = 2
	while roads > 0:
		res += cur
		cur += 1
		roads -= 1
else:
	res = n - 1
print(res)


(n, v) = [int(s) for s in input().split(' ')]
res = 0
need = n - 1
start = min(need, v)
after = need - start
print(int(start + (3 + after) * after / 2))


(n, v) = map(int, input().split())
(curr_litres, cost, req_litres) = (0, 0, n - 1)
for i in range(1, n):
	lit_to_fill = min(req_litres, v - curr_litres)
	curr_litres += lit_to_fill
	curr_litres -= 1
	cost += lit_to_fill * i
	req_litres -= lit_to_fill
print(cost)


import sys
(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	ans = v
	got = v
	for i in range(2, n):
		if got >= n - 1:
			break
		got += 1
		ans += i
	print(ans)


(n, v) = map(int, input().split())
pos = 1
cost = v
if n - 1 <= v:
	print(n - 1)
else:
	while pos + v < n:
		pos += 1
		cost += pos
	print(cost)


a = [int(s) for s in input().split()]
n = a[0]
v = a[1]
s = n - 1
d = min(v, s)
su = 0
n1 = 0
if s > v:
	n1 = s - v
	an = n1 + 1
	a1 = 2
	su = (a1 + an) * n1 // 2
	print(su + v)
else:
	print(d)


(n, v) = [int(i) for i in input().split()]
x = v - 1
for i in range(1, n - v + 1):
	x += i
if n - 1 == x or n - 1 <= v:
	print(n - 1)
else:
	print(x)


(n, m) = map(int, input().split())
x = n - m
if x <= 1:
	print(n - 1)
else:
	print(m + x * (x + 1) // 2 - 1)


(n, u) = map(int, input().split())
res = u
if u >= n:
	res = n - 1
else:
	for i in range(2, n - u + 1):
		res += i
print(res)


(n, v) = map(int, input().split())
res = 0
tank = 0
for i in range(1, n):
	if tank < v and tank < n - i:
		buy = min(v - tank, n - i - tank)
		tank += buy
		res += i * buy
	tank -= 1
print(res)


(n, max_V) = map(int, input().split())
(i, V, money, rest) = (1, 0, 0, n - 1)
while i < n:
	liters = min(max_V - V, rest)
	(i, V, money, rest) = (i + 1, V + liters - 1, money + i * liters, rest - liters)
print(money)


def fn(n, v):
	if v >= n - 1:
		return n - 1
	else:
		k = n - v
		return v + (k * (k + 1) // 2 - 1)
(n, v) = [int(x) for x in input().split()]
print(fn(n, v))


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
	exit()
k = (n - v) * (n - v + 1) // 2 + (v - 1)
ans = max(0, k)
print(ans)


(n, v) = [int(x) for x in input().split()]
dollars = 0
i = 2
if n - v > 0:
	dollars += v
elif n - v == 0:
	dollars += v - 1
else:
	dollars = n - 1
n -= v
while n - 1 > 0:
	dollars += i
	n -= 1
	i += 1
print(dollars)


(n, v) = [int(x) for x in input().split()]
fuel = 0
price = 0
dist = n - 1
if v < n:
	fuel = v
else:
	fuel = n - 1
price = fuel
for i in range(2, n + 1):
	dist = dist - 1
	fuel = fuel - 1
	if fuel < dist:
		fuel = fuel + 1
		price = price + i
print(price)


t = input()
l = list(map(int, t.split(' ')))
c = 0
n = l[0]
m = l[1]
if m >= n - 1:
	print(n - 1)
elif m == 1:
	s = 0
	for i in range(1, n):
		s = s + i
	print(s)
else:
	c = m
	for i in range(1, n):
		if m == n - i:
			break
		else:
			c = c + i + 1
	print(c)


(x, y) = map(int, input().split())
t = x - y
print(y + (t * (t + 1) // 2 - 1) if x > y else x - 1)


from __future__ import print_function
import sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true = True
false = False
null = None
SLOW = True
try:
	range = xrange
except:
	ignored = 1

def fast():
	global SLOW
	SLOW = False

def compute(val, func):
	return func(val)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return '{0:.{1}f}'.format(val, nd)

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def e1e(d, e):
	return d * 10 ** e
mod = e1e(1, 9) + 7
try:
	memoi = functools.lru_cache(None)
except:

	class memoize(dict):

		def __init__(self, f):
			self.f = f

		def __call__(self, *args):
			return self[args]

		def __missing__(self, key):
			ans = self[key] = self.f(*key)
			return ans
	memoi = memoize

class ndarray(list):

	def __init__(self, defval, sizes):
		self.sizes = sizes
		self.dimension = len(sizes)
		self.pm = pm = list(sizes)
		pm.append(1)
		for ii in reversed(range(self.dimension)):
			pm[ii] *= pm[ii + 1]
		list.__init__(self, [defval] * pm[0])

	def ___i1d___(self, ixs):
		if len(ixs) != self.dimension:
			raise LookupError('Dimension must be {}.'.format(self.dimension))
		ans = 0
		for ii in range(self.dimension):
			ix = ixs[ii]
			if ix >= self.sizes[ii]:
				raise IndexError('Index[{}]={} >= Len[{}]={}.'.format(ii, ix, ii, self.sizes[ii]))
			ans += ix * self.pm[ii + 1]
		return ans

	def __getitem__(self, ixs):
		ixs = self.___i1d___(ixs)
		return list.__getitem__(self, ixs)

	def __setitem__(self, ixs, val):
		ixs = self.___i1d___(ixs)
		list.__setitem__(self, ixs, val)

	def _str_(self, dim0=0, ofs=0):
		lft = '  ' * dim0
		if dim0 + 1 == self.dimension:
			return lft + str(list.__getitem__(self, slice(ofs, ofs + self.sizes[dim0])))
		ans = []
		for ii in range(self.sizes[dim0]):
			ans.append(self._str_(dim0 + 1, ofs))
			ofs += self.pm[dim0 + 1]
		ans = '{0}[\n{1}\n{0}]'.format(lft, ',\n'.join(ans))
		return ans

	def __str__(self):
		return self._str_()

def arrays(defval, *sizes):
	if len(sizes) == 1:
		return [defval] * sizes[0]
	return ndarray(defval, sizes)

def perr(*args, **kwargs):
	if SLOW:
		print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

def lines(n):
	return [line() for i in range(n)]

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
		elif isinstance(o, str):
			o = split(o)
	return list(map(num, o or split()))

def loop(f, n=0):
	for tcid in range(n or 99999999):
		f(tcid + 1)

def mainloop(tcid):
	ignored = 1

	def aaa():
		(n, v) = nums()
		ans = min(v, n - 1)
		if v < n - 1:
			aa = n - v
			bb = (2 + aa) * (aa - 2 + 1) // 2
			ans += bb
		print(ans)
	aaa()
tcmax = 0
loop(mainloop, tcmax)


(n, v) = [int(t) for t in input().split(' ')]
cost = min(v, n - 1)
i = 2
while n - i >= v:
	cost += i
	i += 1
print(cost)


(n, v) = map(int, input().split(' '))
ct = n - 1
if ct <= v:
	print(ct)
else:
	c = v
	i = 2
	d = ct - v
	while d != 0:
		d = d - 1
		c += i
		i += 1
	print(c)


(n, v) = map(int, input().split())
req = n - 1
req -= min(n - 1, v)
result = min(n - 1, v)
for i in range(2, n):
	if req > 0:
		result += i
		req -= 1
	else:
		break
print(result)


def minCost(n, v):
	cutPoint = n - v
	initCost = v - 1
	if cutPoint < 0:
		cutPoint = 0
		initCost = n - 1
	interCost = (1 + cutPoint) * cutPoint // 2
	return interCost + initCost
inpt = list(map(int, input().split()))
print(minCost(inpt[0], inpt[1]))


(n, v) = map(int, input().split())
s = n - 1
ANS = 0
i = 2
import sys
if s <= v:
	ANS += s
	print(ANS)
	sys.exit(0)
ANS += 1 * v
while s != 0:
	if s == v:
		s -= v
	if s > v:
		s -= 1
		ANS += 1 * i
	i += 1
print(ANS)


(n, v) = input().split()
n = int(n)
v = int(v)
if n - 1 < v:
	print(n - 1)
elif n - 1 == v:
	print(v)
else:
	city = 1
	cost = v
	i = 2
	j = 1
	while city < n - v:
		cost += i
		i += 1
		city += 1
	if city == n - v:
		print(cost)
	else:
		print('v')
		print(cost + i)


(n, v) = map(int, input().strip().split())
answer = 0
n -= 1
if n <= v:
	print(n)
else:
	answer = v
	for i in range(1, n - v + 1):
		answer += i + 1
	print(answer)


r = input().split()
a = r[0]
b = r[1]
if int(b) >= int(a) - 1:
	print(int(a) - 1)
else:
	num = int(b)
	t = int(b)
	for i in range(2, int(a)):
		t -= 1
		if t < int(a) - i:
			num += i
			t += 1
	print(num)


import sys
from collections import deque
import math
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
li = lambda : list(input_())
pr = lambda x: print(x)
f = lambda : sys.stdout.flush()
(n, v) = il()
m = n - 1
if v >= n:
	print(n - 1)
else:
	print(v - 1 + (n - v) * (n - v + 1) // 2)


def find(n, v):
	res = 0
	k = 0
	for i in range(1, n + 1):
		if k <= 0 or i + k < n:
			tmp = min(n - i - k, v - k)
			k += tmp
			res += i * tmp
		k -= 1
	return res

def main():
	(n, v) = map(int, input().split())
	print(find(n, v))
main()


(n, v) = map(int, input().split())
p = min(n - 1, v)
for i in range(1, max(1, n - v)):
	p += i + 1
print(p)


inp = input().split()
n = int(inp[0])
v = int(inp[1])
if n <= v:
	print(n - 1)
else:
	cost = v
	city = [i for i in range(1, n + 1)]
	for i in range(1, len(city)):
		if n - i == v:
			break
		cost = cost + city[i]
	print(cost)


(dis, cap) = map(int, input().split())
cost = 0
if dis <= cap:
	cost = dis - 1
else:
	cost += cap
	for i in range(2, dis - cap + 1):
		cost += i
print(cost)


def solve(n, v):
	if n <= v:
		return n - 1
	Fuel = v
	Money = v
	Start = 1
	while n - Fuel != 0:
		Money += Start + 1
		Fuel += 1
		Start += 1
	return Money - Start
(n, v) = map(int, input().split())
print(solve(n, v))


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	a = v
	b = 0
	b = v
	req = n - 1
	req = n - 1 - v
	i = 2
	while req != 0:
		req = req - 1
		a = a + i
		i += 1
	print(a)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	for i in range(n):
		if i == 0:
			k = v
		else:
			k += i + 1
		if i + v == n - 1:
			break
	print(k)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	count = v
	cost = v
	i = 2
	while count < n - 1:
		cost = cost + i
		i = i + 1
		count = count + 1
	print(cost)


(n, v) = map(int, input().split())
cur = 0
total = 0
for i in range(n):
	while cur < n - i - 1:
		cur += 1
		total += i + 1
		if cur == v:
			break
	cur -= 1
print(total)


(n, k) = map(int, input().split())
a = k
if k >= n - 1:
	print(n - 1)
else:
	for i in range(n - 1 - k):
		a += i + 2
	print(a)


(n, v) = [int(y) for y in input().split(' ')]
if v >= n - 1:
	print(n - 1)
else:
	d = v - 1
	n = n - 1
	n = n - (v - 1)
	d = d + n * (n + 1) // 2
	print(d)


inp = [int(x) for x in input().strip().split(' ')]
cities = inp[0]
tank = inp[1]
fuel = 0
cost = 0
if cities <= tank:
	cost = cities - 1
else:
	cost = tank
	fuel = tank
	for i in range(2, cities):
		fuel -= 1
		if fuel < cities - i:
			refill = cities - i - fuel
			if tank - fuel >= refill:
				fuel += refill
				cost += refill * i
			else:
				val = tank - fuel
				fuel += val
				cost += val * i
		else:
			i = cities
print(cost)


def _func(remained_cities, max_tank_value, cur_city_number, cur_tank_value, spend_money):
	if remained_cities == 0:
		return spend_money
	else:
		if remained_cities > cur_tank_value:
			bay_liters = min(remained_cities, max_tank_value) - cur_tank_value
		else:
			bay_liters = 0
		return _func(remained_cities=remained_cities - 1, max_tank_value=max_tank_value, cur_city_number=cur_city_number + 1, cur_tank_value=cur_tank_value + bay_liters - 1, spend_money=spend_money + bay_liters * cur_city_number)

def func(n, v):
	return _func(remained_cities=n - 1, max_tank_value=v, cur_city_number=1, cur_tank_value=0, spend_money=0)
input_str = input().split(' ')
(n, v) = map(lambda _: int(_), input_str)
print(func(n, v))


(n, v) = map(int, input().split())
f = 0
c = 1
d = 0
while True:
	af = min(v - f, n - c)
	f += af
	d += af * c
	if n - c == f:
		break
	c += 1
	f -= 1
print(d)


l = input().split()
n = int(l[0])
v = int(l[1])
t = v
if v >= n:
	t = n - 1
for i in range(2, n - v + 1):
	t += i
print(t)


(p, k) = map(int, input().split())
if k >= p - 1:
	n = p - 1
else:
	n = p - k
	n = n * (n + 1) // 2 - 1 + k
print(n)


a = input().split()
km_count = int(a[0]) - 1
max_tank_size = int(a[1])
money_paid = 0
current_km = 1
current_tank = 0
tank_km = 0
while km_count > tank_km:
	if current_tank == max_tank_size:
		current_km += 1
		current_tank -= 1
		continue
	money_paid += current_km
	current_tank += 1
	tank_km += 1
print(money_paid)


(n, v) = map(int, input().split())
m = v
req = n - 1 - v
if n - 1 <= v:
	print(n - 1)
else:
	for i in range(2, req + 2):
		m += i
	print(m)


(n, v) = map(int, input().split())
i = 1
n -= 1
ans = 0
sek = min(n, v)
ans += sek * i
n -= sek
while n != 0:
	i += 1
	n -= 1
	ans += i
print(ans)


(n, v) = map(int, input().split())
ans = 0
i = 1
w = 0
while True:
	dw = min(v - w, n - i - w)
	if dw <= 0:
		break
	w += dw
	ans += i * dw
	i += 1
	w -= 1
print(ans)


(n, v) = [int(i) for i in input().split()]
answer = 0
if v >= n - 1:
	answer = n - 1
else:
	fuel = 0
	for i in range(1, n + 1):
		if fuel < n - i and n - i > v:
			answer += i * (v - fuel)
			fuel += v - fuel
		elif fuel < n - i and n - i <= v:
			answer += i * (n - i - fuel)
			fuel += n - i - fuel
		fuel -= 1
print(answer)


gi = lambda : list(map(int, input().strip().split()))
(n, v) = gi()
p = 2
g = min(v, n - 1) - 1
ans = g + 1
while p < n:
	if g < n - p and g < v:
		g += 1
		ans += p
	g -= 1
	p += 1
print(ans)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
else:
	x = 1
	ans = v
	while x < n - v:
		x += 1
		ans += x
	print(ans)


(n, v) = map(int, input().split())
if n - 1 <= v:
	print(n - 1)
else:
	rs = v
	d = v
	s = 2
	while d < n - 1:
		d += 1
		rs += 1 * s
		s += 1
	print(rs)


IL = lambda : list(map(int, input().split()))
(n, v) = IL()
ans = min(v, n - 1)
for i in range(2, n):
	if v - 1 < n - i:
		ans += i
print(ans)


R = lambda : map(int, input().split())
(n, v) = R()
(f, c) = (0, 0)
for i in range(1, n):
	af = min(v, n - i) - f
	c += af * i
	f += af
	f -= 1
print(c)


[n, k] = list(map(int, input().split()))
ans = 0
rest = 0
if n > k + 1:
	rest += k
	ans += k
	for i in range(2, n - 1 - k + 2):
		ans += i
else:
	ans += n - 1
print(ans)


(n, v) = map(int, input().split())
if v >= n - 1:
	print(n - 1)
	exit()
ans = v
x = v
for i in range(n):
	if x == n - 1:
		break
	ans += i + 2
	x += 1
print(ans)


temp = input().split()
n = int(temp[0])
v = int(temp[1])
need = n - 1
cap = 0
sum = 0
if v >= need:
	print(n - 1)
	exit(0)
else:
	cap = v
	sum = v
counter = 2
while cap < need:
	cap = cap + 1
	sum = sum + counter
	counter = counter + 1
print(sum)


(n, m) = map(int, input().split(' '))
t = 1
c = m
if n <= m:
	print(n - 1)
else:
	c1 = [i for i in range(1, n + 1)]
	for i in range(1, len(c1)):
		if n - i == m:
			break
		c = c + c1[i]
	print(c)


import sys
input = sys.stdin.readline
prnt = sys.stdout.write
(n, v) = map(int, input().split())
res = 0
if n - 1 <= v:
	res = n - 1
else:
	res = v
	for i in range(2, n - v + 1):
		res += i
prnt(str(res))


info = input().split()
cities = int(info[0])
capacity = int(info[1])
rta = 0
first = True
actual = 0
for i in range(cities):
	if first:
		if cities > capacity:
			first = False
			rta += capacity
			actual = capacity
		else:
			rta = cities - 1
			break
	elif i + 1 == cities:
		break
	elif actual == cities - i:
		break
	else:
		rta += i + 1
print(rta)


(n, v) = map(int, input().split())
ans = 0
num = min(n - 1, v)
ans += num
for i in range(2, n + 1):
	num -= 1
	if n - i > num:
		ans += i
		num += 1
print(ans)


(cities, tank) = map(int, input().split())
fuel_cost = 0
if cities > tank:
	fuel_cost = tank
	for i in range(2, cities + 1 - tank):
		fuel_cost += i
else:
	fuel_cost = cities - 1
print(fuel_cost)


(n, vm) = map(int, input().split())
nuzno = n - 1
i = 1
if nuzno <= vm:
	print(nuzno)
else:
	suma = vm
	obsh = vm
	while obsh != nuzno:
		i += 1
		suma += i
		obsh += 1
	print(suma)


(n, v) = [int(x) for x in input().split()]
if v >= n - 1:
	print(n - 1)
else:
	cost = 0
	for i in range(1, n + 1):
		if i == 1:
			cost += i * v
			v -= 1
		elif v >= n - i:
			print(cost)
			break
		else:
			cost += i


(n, v) = map(int, input().strip().split())
x = n - v - 1
if v < n:
	s = v
else:
	s = n - 1
for i in range(2, x + 2):
	s += i
print(s)


sigma = lambda n: n * (n + 1) // 2 - 1
ll = lambda : list(map(int, input().split()))
[n, v] = ll()
if v + 1 >= n:
	print(n - 1)
else:
	print(v + sigma(n - v))


(n, v) = map(int, input().split())
total = 0
gas = 0
for i in range(1, n):
	if gas < n - i:
		new = min(v - gas, n - i)
		gas += new
		total += i * new
	gas -= 1
print(total)


(N, V) = list(map(int, input().split(' ')))
res = min(N, V)
if N <= V:
	res -= 1
N = N - V
if N > 0:
	res += N * (N + 1) // 2 - 1
print(res)


(n, v) = list(map(int, input().split()))
n -= 1
s = min(v, n) + 0
i = 2
j = v + 0
while j < n:
	s += i
	i += 1
	j += 1
print(s)


(n, v) = map(int, input().split())
if n - 1 < v:
	print(n - 1)
else:
	m = v - 1
	p = n - v + 1
	i = v - 1
	while p > 0:
		m += i - v + 1
		i += 1
		p -= 1
	print(m)