Each evening after the dinner the SIS's students gather together to play the game of Sport Mafia. 

For the tournament, Alya puts candies into the box, which will serve as a prize for a winner. To do that, she performs $n$ actions. The first action performed is to put a single candy into the box. For each of the remaining moves she can choose from two options:

  the first option, in case the box contains at least one candy, is to take exactly one candy out and eat it. This way the number of candies in the box decreased by $1$;  the second option is to put candies in the box. In this case, Alya will put $1$ more candy, than she put in the previous time. 

Thus, if the box is empty, then it can only use the second option.

For example, one possible sequence of Alya's actions look as follows:

  put one candy into the box;  put two candies into the box;  eat one candy from the box;  eat one candy from the box;  put three candies into the box;  eat one candy from the box;  put four candies into the box;  eat one candy from the box;  put five candies into the box; 

This way she will perform $9$ actions, the number of candies at the end will be $11$, while Alya will eat $4$ candies in total.

You know the total number of actions $n$ and the number of candies at the end $k$. You need to find the total number of sweets Alya ate. That is the number of moves of the first option. It's guaranteed, that for the given $n$ and $k$ the answer always exists.

Please note, that during an action of the first option, Alya takes out and eats exactly one candy.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \le n \le 10^9$; $0 \le k \le 10^9$) — the total number of moves and the number of candies in the box at the end. 

It's guaranteed, that for the given $n$ and $k$ the answer exists.


-----Output-----

Print a single integer — the number of candies, which Alya ate. Please note, that in this problem there aren't multiple possible answers — the answer is unique for any input data. 


-----Examples-----
Input
1 1

Output
0
Input
9 11

Output
4
Input
5 0

Output
3
Input
3 2

Output
1


-----Note-----

In the first example, Alya has made one move only. According to the statement, the first move is always putting one candy in the box. Hence Alya ate $0$ candies.

In the second example the possible sequence of Alya's actions looks as follows:   put $1$ candy,  put $2$ candies,  eat a candy,  eat a candy,  put $3$ candies,  eat a candy,  put $4$ candies,  eat a candy,  put $5$ candies.  

This way, she will make exactly $n=9$ actions and in the end the box will contain $1+2-1-1+3-1+4-1+5=11$ candies. The answer is $4$, since she ate $4$ candies in total.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics

Complete search


Solutions:
import math
(n, k) = map(int, input().split())
s = n * (n + 1) // 2
if int((2 * n + 3 - math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2) >= 0 and int((2 * n + 3 + math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2) >= 0:
	print(min(int((2 * n + 3 - math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2), int((2 * n + 3 + math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2)))
else:
	print(max(int((2 * n + 3 - math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2), int((2 * n + 3 + math.sqrt((2 * n + 3) ** 2 - 4 * (n * (n + 1) - k * 2))) // 2)))


(n, k) = map(int, input().split())
a = 1
b = -(2 * n + 3)
c = n * n + n - 2 * k
d = b ** 2 - 4 * a * c
x1 = (-b + d ** 0.5) / (2 * a)
x2 = (-b - d ** 0.5) / (2 * a)
if x1 == int(x1) and x1 < n:
	print(int(x1))
if x2 == int(x2) and x2 < n:
	print(int(x2))


(x, y) = map(int, input().split())
sum1 = 0
q = 0
for i in range(1, x + 1):
	p = x - i
	if p < 0:
		print(0)
		break
	q = q + i
	r = q
	r = r - p
	if r == y:
		print(p)
		break


(n, k) = list(map(int, input().split()))
c = 1
while c * (c + 1) // 2 < k:
	c += 1
while c * (c + 1) // 2 - (n - c) != k:
	c += 1
print(n - c)


(n, k) = [int(x) for x in input().split()]
summ = 0
for i in range(1, n + 1):
	summ += i
	candy = summ - (n - i)
	if candy == k:
		index = i
		break
print(n - index)


def func(n, m):
	return (1 + (n - m)) * (n - m) // 2 - m
(n, k) = map(int, input().split())
l = 0
r = n
while l <= r:
	m = (l + r) // 2
	f = func(n, m)
	if f < k:
		r = m
	elif f > k:
		l = m
	else:
		print(m)
		exit(0)


from math import sqrt
(n, k) = map(int, input().split())
put = int(-3 + sqrt(9 + 8 * (k + n))) // 2
print(n - put)


import math
(n, k) = map(int, input().split())
d = 9 + 8 * n + 8 * k
x = (-3 + math.sqrt(d)) // 2
print(int(n - x))


(n, k) = map(int, input().split())
ans1 = (2 * n + 3 + ((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)) ** 0.5) / 2
ans2 = (2 * n + 3 - ((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)) ** 0.5) / 2
print(int(min(ans1, ans2)))


(n, k) = map(int, input().split())
x1 = -3 + int((9 + 8 * (n + k)) ** 0.5)
print(n - x1 // 2)


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


import math
List = list(map(int, input().strip().split()))[0:2]
n = List[0]
r = List[1]
Result = n - int((math.sqrt(9 + 8 * (n + r)) - 3) / 2)
print(Result)


from math import sqrt as sqrt
(n, k) = map(int, input().split())
t = int(sqrt(8 * n + 8 * k + 9) + 0.0001)
m = (t - 3) // 2
print(n - m)


read = lambda : map(int, input().split())

def main():
	(n, k) = read()
	for x in range(1, n + 1):
		cnt = (1 + x) * x / 2
		if cnt - n + x == k:
			print(n - x)
			break
main()


(n, k) = map(int, input().split())
low = 1
high = n
import sys
while low <= high:
	mid = (low + high) // 2
	if mid * (mid + 1) // 2 - (n - mid) > k:
		high = mid - 1
	elif mid * (mid + 1) // 2 - (n - mid) == k:
		print(n - mid)
		sys.exit()
	else:
		low = mid + 1


query = input().split()
n = int(query[0])
k = int(query[1])
import math
temp = 2 * (k + n)
m = (-3 + math.sqrt(9 + 4 * temp)) / 2
print(int(n - m))


(n, k) = map(int, input().split())
x = 0
i = 1
while i * (i + 1) / 2 != k + n - i:
	i += 1
print(n - i)


import math
(n, k) = map(int, input().strip().split())
print(round(n + 1.5 - math.sqrt(2 * (n + k) + 2.75)))


(n, k) = map(int, input().split())
i = 1
while i * (i + 1) // 2 != k + n - i:
	i += 1
print(n - i)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
(a, b) = (1, n + 1)
ans = 0
while a <= b:
	mid = a + (b - a) // 2
	s = mid * (mid + 1) // 2
	if s - k == n - mid:
		ans = n - mid
		break
	elif s - k < n - mid:
		a = mid + 1
	else:
		b = mid - 1
print(ans)


(n, k) = map(int, input().split())
t = (-3 + (9 + 8 * n + 8 * k) ** (1 / 2)) // 2
print(int(n - t))


from math import sqrt

def p3():
	(n, k) = map(int, input().split(' '))
	ans = int(n - (-3 + sqrt(9 + 8 * (n + k))) / 2)
	print(ans)

def main():
	p3()
main()


def progression(num):
	return num * (num + 1) / 2
(n, k) = [int(i) for i in input().split()]
progr = 0
i = 0
while progr - n + i != k:
	i += 1
	progr = progression(i)
print(n - i)


from sys import *
input = stdin.readline
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())
sJoin = lambda a, sep: f'{sep}'.join(a)
arrJoin = lambda a, sep: f'{sep}'.join(map(str, a))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def main():
	(n, k) = lineInput()
	(low, high) = (0, n - 1)
	while low <= high:
		mid = (low + high) // 2
		total = (n - mid) * (n - mid + 1) // 2
		if total - mid == k:
			print(mid)
			break
		elif total - mid < k:
			high = mid - 1
		else:
			low = mid + 1
main()


import sys
from collections import defaultdict

def main():
	(n, k) = map(int, input().split())
	cand = 0
	tot = 0
	p = 0
	while tot < k or tot - (n - p) != k:
		cand += 1
		tot += cand
		p += 1
	print(tot - k)
main()


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	t = 1
	for tt in range(t):
		(n, k) = num()
		d = ma.sqrt(9 + 8 * (n + k))
		gp = (-3 + d) / 2
		print(int(n - gp))
solve()


import math
(n, k) = map(int, input().split(' '))
b = 2 * n + 3
c = n * n + n - 2 * k
d = math.sqrt(b * b - 4 * c)
ans1 = (-b + d) / 2
ans2 = (-b - d) / 2
ans1 = -1 * ans1
ans2 = -2 * ans2
if ans2 < 0 or ans2 > n:
	ans = ans1
else:
	ans = ans2
print(int(ans))


(n, k) = list(map(int, input().split()))

def get_sum(n):
	return (1 + n) * n // 2
l = 0
r = n
while r > l:
	mid = (l + r) // 2
	if get_sum(n - mid) == k + mid:
		l = mid
		r = mid
		break
	elif get_sum(n - mid) < k + mid:
		r = mid
	else:
		l = mid + 1
print(l)


from math import *
S1 = input().split(' ')
out = int(int(S1[0]) - (-3 + sqrt(9 + 8 * (int(S1[0]) + int(S1[1])))) / 2)
print(out)


import math

def f(n, k):
	m = int(math.sqrt(n + k + 1 << 1))
	return n - m + 1
(n, k) = list(map(int, input().split()))
print(f(n, k))


def binary(n, k):
	lower = 1
	upper = n
	while lower < upper:
		mid = (lower + upper) // 2
		total = mid * (mid + 1) // 2
		if n - mid == total - k:
			print(n - mid)
			break
		elif n - mid > total - k:
			lower = mid + 1
		else:
			upper = mid
(n, k) = map(int, input().split())
if n == 1 and k == 1:
	print(0)
else:
	binary(n, k)


import math
(N, K) = map(int, input().split())
A = 1
B = -N - N - 3
C = N * N + N - 2 * K
rootarg = B ^ 2 - 4 * A * C
root = math.sqrt(B * B - 4 * A * C)
x1 = (-B + root) / (2 * A)
x2 = (-B - root) / (2 * A)
raw = [int(x1), int(x2)]
rezults = list(filter(lambda x: x >= 0 and x <= N, raw))
print(rezults[0])


(n, k) = map(int, input().split())
action = 1
candy = 0
while True:
	candy += action
	if n - action == candy - k:
		break
	action += 1
print(candy - k)


(n, k) = map(int, input().split())
print(int(abs(n + 1.5 - (2 * (n + k) + 2.25) ** 0.5)))


(n, k) = map(int, input().split())
c = n + k
p = int(0.5 * ((8 * c + 9) ** 0.5 - 3))
print(n - p)


from sys import stdin
from math import ceil
(n, k) = map(int, stdin.readline().strip().split())

def sol(n, k):
	x = n * (n + 1)
	x = x // 2
	return x - k
low = 0
high = n + 1
while high - low > 1:
	mid = (high + low) // 2
	x = sol(mid, k)
	if x + mid <= n:
		low = mid
	else:
		high = mid
if sol(high, k) + high == n:
	print(sol(high, k))
else:
	print(sol(low, k))


(n, k) = map(int, input().split())
root = (9 + 8 * (k + n)) ** 0.5
m = (-3 + root) / 2
print(int(n - m))


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

def search(x, n):
	(left, right) = (0, n)
	while left <= right:
		middle = left + (right - left) // 2
		if fn(middle) - (n - middle) == x:
			return n - middle
		elif fn(middle) - (n - middle) > x:
			right = middle - 1
		else:
			left = middle + 1
	return -1
(n, k) = [int(i) for i in input().split()]
print(search(k, n))


import sys
sys.setrecursionlimit(1000)

def estimate(a):
	return int((n - a) * (n + 1 - a) / 2) - a

def dicho(lower, upper, target):
	if estimate(lower) == target:
		return lower
	elif estimate(upper) == target:
		return upper
	else:
		mid = int((lower + upper) / 2)
		if estimate(mid) < target:
			upper = mid
		else:
			lower = mid
		return dicho(lower, upper, target)
(n, k) = map(int, input().split())
lower = 0
upper = n
print(dicho(lower, upper, k))


(n, k) = [int(i) for i in input().split(' ')]
i = 0
x = i * (i + 1) // 2
while x - (n - i) != k:
	i += 1
	x = i * (i + 1) // 2
print(n - i)


tri = 0
(n, k) = [int(i) for i in input().split()]
ind = 1
sm = n + k
for q in range(1 << 20):
	tri += ind
	if tri + ind == sm:
		print(n - ind)
		break
	ind += 1


import math
(n, k) = map(int, input().split())
i = int((-3 + math.sqrt(9 + 8 * n + 8 * k)) / 2)
print(n - i)


(moves, candies) = map(int, input().split())
curr = 0
for z in range(1, moves + 1):
	curr = curr + z
	if curr - (moves - z) == candies:
		print(moves - z)
		break


from math import sqrt
iarr = list(map(int, input().split()))
n = iarr[0]
k = iarr[1]
b = 2 * n + 3
c = 4 * (n + n * n - 2 * k)
und = int(sqrt(b * b - c))
ans = (b - und) // 2
print(ans)


def binary(n, k, low, high):
	if low <= high:
		mid = (low + high) // 2
		if mid * (mid + 1) // 2 - (n - mid) == k:
			return n - mid
		elif mid * (mid + 1) // 2 - (n - mid) > k:
			return binary(n, k, low, mid - 1)
		else:
			return binary(n, k, mid + 1, high)
(n, k) = [int(x) for x in input().split()]
print(binary(n, k, 1, n))


(n, left) = map(int, input().split())
s = 0
for i in range(1, n + 1):
	s += i
	if s - (n - i) == left:
		print(n - i)
		break


import collections
(n, k) = map(int, input().split())
(l, r) = (0, n)
while l <= r:
	m = (l + r) // 2
	t = n - m
	if m * (m + 1) // 2 - t == k:
		ans = t
		break
	elif m * (m + 1) // 2 - t < k:
		l = m + 1
	else:
		r = m - 1
print(ans)


(n, k) = map(int, input().split(' '))
if k == 1 and n == 1:
	print(0)
else:
	f = int(k ** 0.5)
	while f * (3 + f) != 2 * (n + k):
		f += 1
	print(n - f)


import sys
import math
input = sys.stdin.readline
(n, k) = map(int, input().split())
arr = [1]
cur = 2
while arr[-1] <= 3000000000:
	arr.append(cur * (cur + 1) // 2)
	cur += 1
for i in range(len(arr)):
	if arr[i] - k + i + 1 == n:
		print(arr[i] - k)
		break


(n, k) = map(int, input().split())
if k == n * (n + 1) // 2:
	print(0)
else:
	left = 0
	right = n
	while left < right:
		mid = (left + right) // 2
		candies = mid * (mid + 1) // 2
		if candies + mid < k + n:
			left = mid + 1
		else:
			right = mid
	print(n - left)


(n, k) = map(int, input().split())
current = 1
actions = 1
step = 2
while n != actions + (current - k):
	current += step
	step += 1
	actions += 1
print(current - k)


(n, k) = map(int, input().split())
l = 1
r = n
while l <= r:
	m = (r + l) // 2
	if m * (m + 1) / 2 - (n - m) == k:
		print(n - m)
		break
	elif m * (m + 1) / 2 - (n - m) < k:
		l = m + 1
	else:
		r = m - 1


def bs(l, r, k, p):
	if r >= l:
		mid = l + (r - l) // 2
		x = mid * (mid + 1) // 2 - (p - mid)
		if x == k:
			return mid
		elif x > k:
			return bs(l, mid - 1, k, p)
		else:
			return bs(mid + 1, r, k, p)
	else:
		return -1
(n, k) = map(int, input().split())
ans = bs(0, n, k, n)
print(n - ans)


import sys
input = lambda : sys.stdin.readline().strip()
from math import *
(n, k) = map(int, input().split())
t = (int(sqrt(9 + 8 * n + 8 * k)) - 3) // 2
print(n - t)


(n, k) = map(int, input().split())
c = 0
t = 0
while c != n:
	if t - (n - c) == k:
		break
	c += 1
	t += c
print(t - k)


import math
(n, k) = [int(i) for i in input().split()]
i1 = int(-3 / 2 + math.sqrt(9 / 4 + 2 * n + 2 * k))
print(n - i1)


def binary_search(n, k):
	left = -1
	right = n
	while left < right - 1:
		middle = (left + right) // 2
		if middle % 2 != 0:
			s = (1 + middle) * (middle // 2) + (1 + middle) // 2
		else:
			s = (1 + middle) * (middle // 2)
		if s - (n - middle) >= k:
			right = middle
		else:
			left = middle
	return right
(n, k) = map(int, input().split())
i = 1
count = 0
print(n - binary_search(n, k))


def sumOfNNumbers(first, last, n):
	return n * (first + last) // 2

def BinarySeach(n, k):
	start = 1
	end = n
	while start <= end:
		mid = (start + end) // 2
		if sumOfNNumbers(1, mid - 1, mid - 1) - (n - mid + 1) == k:
			return n - mid + 1
		elif sumOfNNumbers(1, mid - 1, mid - 1) - (n - mid + 1) > k:
			end = mid - 1
		else:
			start = mid + 1
(n, k) = map(int, input().split())
if n == 1:
	print(0)
else:
	print(BinarySeach(n, k))


(n, k) = map(int, input().split())
b = n // 2 + 1
lo = 0
hi = n
while True:
	r = (2 + b - 1) * b // 2
	ans = r - (n - b)
	if ans == k:
		print(n - b)
		exit()
	elif ans < k:
		lo = b
		b = (hi + b) // 2
	else:
		hi = b
		b = (lo + b) // 2


from math import sqrt
(n, k) = map(int, input().split())
a = n ** 2 + n - 2 * k
b = 2 * n + 3
d = sqrt(b ** 2 - 4 * a)
ans = (b - d) // 2
print(int(ans))


import sys
import math

def main():
	(n, k) = [int(s) for s in sys.stdin.readline().strip().split()]
	x = (2 * n + 3 - math.sqrt(9 + 8 * (n + k))) / 2
	print(int(x))
main()


import math
(n, k) = list(map(int, input().split()))
d = float((2 * n + 3) * (2 * n + 3) - 4 * 1 * (n + n * n - 2 * k))
x1 = int((2 * n + 3 - math.sqrt(d)) / 2)
x2 = int((2 * n + 3 + math.sqrt(d)) / 2)
if x1 >= x2:
	print(x2)
else:
	print(x1)


def candies(n):
	return n * (n + 1) // 2
(n, k) = list(map(int, input().split()))
for i in range(min(10 ** 5, n) + 1):
	if candies(i) - (n - i) == k:
		print(n - i)
		break


from sys import stdin, stdout
from collections import Counter
import math

def rsingle_int():
	return int(stdin.readline().rstrip())

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

def r_str():
	return stdin.readline().rstrip()

def rsingle_char():
	return stdin.read(1)

def main():
	(n, k) = rmult_int()
	b = 2 * n + 3
	c = n * n + n - 2 * k
	det = int(math.sqrt(b * b - 4 * c))
	sol2 = int((b - det) / 2)
	print(sol2)
main()


(n, k) = [int(i) for i in input().split()]
from math import *
a = int(sqrt(8 * n + 8 * k + 9))
x = (2 * n + 3 - a) // 2
print(x)


import math
(N, K) = list(map(int, input().split()))
Find = math.sqrt(9 + 8 * (N + K))
print(N - int(math.ceil((-3 + Find) / 2)))


import math
(n, k) = map(int, input().split())
i = n
flg = 0
while flg == 0:
	if i * (i + 1) // 2 - (n - i) == k:
		flg = 1
		break
	elif i * (i + 1) // 2 - (n - i) > k:
		i = int(math.sqrt(i))
	else:
		i += 1
print(n - i)


(n, k) = map(int, input().split())
l = 0
u = n - 1
while l <= u:
	y = (l + u) // 2
	x = n - y
	m = x * (x + 1) // 2
	if m - y == k:
		print(y)
		break
	elif m - y > k:
		l = y + 1
	else:
		u = y - 1


from sys import stdin
(n, k) = list(map(int, stdin.readline().split(' ')))

def oka(p):
	q = n - p
	return k == p * (p + 1) // 2 - q
p = list(filter(oka, range(1, 100 * 1000)))[0]
q = n - p
print(q)


(n, k) = map(int, input().split())
(left, right) = (1, n + 1)
while left <= right:
	q = (left + right) // 2
	remaining = q * (q + 1) // 2 - (n - q)
	if remaining == k:
		print(n - q)
		break
	elif remaining < k:
		left = q + 1
	else:
		right = q - 1


(n, k) = list(map(int, input().split()))
print(n - round((-3 + (9 + 8 * (n + k)) ** 0.5) / 2))


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
MIN = 0
MAX = n
while True:
	ANS = (MIN + MAX) // 2
	if (n - ANS) * (n - ANS + 1) // 2 - ANS > k:
		MIN = ANS + 1
	elif (n - ANS) * (n - ANS + 1) // 2 - ANS < k:
		MAX = ANS - 1
	else:
		print(ANS)
		break


def mafia(n, k):
	(i, j) = (0, n)
	while j > 0:
		j -= 1
		i += 1
		s = i * (i + 1) // 2
		if s - j == k:
			break
	return j
(N, K) = [int(x) for x in input().split()]
print(mafia(N, K))


import cmath
m = input('')
j = 0
for i in m.split(' '):
	if j == 0:
		n = int(i)
		j = 1
	else:
		k = int(i)
root = cmath.sqrt(8 * n + 8 * k + 9).real
ans = 2 * n + 3 - root
if ans >= 0 and ans % 2 == 0:
	ans = ans / 2
else:
	ans = ans + 2 * root
	ans = ans / 2
ans = int(ans)
print(ans)


(n, k) = [int(i) for i in input().split()]
6
(x, y) = (0, n + 1)
cur = 0
while cur != (x + y) / 2:
	cur = (x + y) // 2
	prek = (n + 1 - cur) / 2 * (n - cur) - cur
	if prek == k:
		break
	elif prek > k:
		x = cur
	else:
		y = cur
print(cur)


inp = input().split()
n = int(inp[0])
k = int(inp[1])
if n == 1 and k == 1:
	print(0)
	exit()
step_counter = n
sum = 0
result = int()
for i in range(1, n):
	if sum - step_counter == k:
		result = step_counter
		break
	else:
		sum += i
		step_counter -= 1
		i += 1
print(step_counter)


(total_turns_count, total_sweets_count) = [int(i) for i in input().split()]
turns_count = 0
sweets_count = 0
while True:
	if sweets_count - total_sweets_count == total_turns_count - turns_count:
		print(total_turns_count - turns_count)
		break
	turns_count += 1
	sweets_count += turns_count


import math
nk = input().split()
n = int(nk[0])
k = int(nk[1])
D = int(math.sqrt(8 * (n + k) + 9))
num1 = 2 * n + 3 + D
num2 = 2 * n + 3 - D
den = 2
ans1 = int(num1 / den)
ans2 = int(num2 / den)
print(ans2)


def mp():
	return map(int, input().split())
(n, k) = mp()
d = (2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)
x = (2 * n + 3 - int(d ** 0.5)) // 2
print(x)


import math as mt
(n, k) = map(int, input().split())
print(mt.floor(n - (-3 + mt.sqrt(9 + 8 * (n + k))) / 2))


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd

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

def si():
	return str(input())

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

def li():
	return list(mi())

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

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)
	print(l)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s
(n, k) = mi()
c = 0
p = 0
s = 0
while s - n < k:
	p += 1
	s += p
	n -= 1
print(n)


(n, k) = map(int, input().split())
for i in range(1, n + 1):
	if (1 + i) * i // 2 - (n - i) == k:
		print(n - i)
		break


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : list(input())
(n, k) = ml()
ans = 0
for i in range(1, 1000001):
	val = i * (i + 1) // 2
	if val - (n - i) == k:
		ans = n - i
print(ans)


l = [int(x) for x in input().split()]
l = l[:2]
n = l[0]
r = l[1]
i = 0
su = 0
re = 0
while 1:
	i = i + 1
	re = i * (i + 1) / 2
	if re >= r:
		su = re - r
	if n == i + su:
		print(int(su))
		break


import math
arr = list(map(int, input().split()))
ans = arr[0] - (math.sqrt(9 + 8 * (arr[0] + arr[1])) - 3) / 2
print(int(ans))


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

def search(x):
	if k <= x * (x + 1) // 2 + x - n:
		return True
	else:
		return False
left = -1
right = n + 1
while right - left > 1:
	mid = left + (right - left) // 2
	if search(mid):
		right = mid
	else:
		left = mid
left
right
print(n - right)


import math
(n, k) = map(int, input().split())
c = 2 * (k + n)
d = math.sqrt(9 + 4 * c)
re = (-3 + d) // 2
rk = (-3 - d) // 2
y = max(re, rk)
print(int(n - y))


(n, k) = map(int, input().split())
x = ((9 + 8 * (n + k)) ** 0.5 - 3) / 2
s = x * (x + 1) / 2
print(round(s - k))


from math import sqrt

def line():
	inp = input().split()
	if len(inp) == 1:
		return int(inp[0])
	return map(int, inp)
(n, k) = line()
print(round((2 * n + 3 - sqrt((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k))) / 2))


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

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

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(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
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = False
from math import factorial

def main():
	(n, k) = get_tuple()
	x = 0
	while x * (x + 1) // 2 < k:
		x += 1
	ate = x * (x + 1) // 2 - k
	n -= x + ate
	while n > 0:
		x += 1
		ate += x
		n -= x + 1
	print(ate)
if TestCases:
	for i in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


from math import sqrt
(n, k) = map(int, input().split())
foo = 2 * k + 2 * n
d = sqrt(9 + 4 * foo)
ans = (d - 3) / 2
print(int(n - ans))


def f(khaya):
	return (n - khaya) * (1 + n - khaya) // 2 - khaya - k
(n, k) = map(int, input().split())
low = 0
high = n
i = 0
while True:
	i += 1
	mid = (high + low) // 2
	ll = f(mid)
	if ll == 0:
		break
	if ll > 0:
		low = mid + 1
	else:
		high = mid - 1
print(mid)


(n, k) = map(int, input().split())
(l, r) = (0, n)
while r - l > 1:
	m = (l + r) // 2
	a = m * (m + 1) // 2 - (n - m)
	if a > k:
		r = m
	else:
		l = m
if k == n * (n + 1) // 2:
	print(0)
else:
	print(n - l)


(n, k) = map(int, input().split())
(ll, rr) = (0, n)
while True:
	t = (ll + rr) // 2
	kk = t * (t + 1) // 2 - (n - t)
	if kk == k:
		print(n - t)
		break
	if kk < k:
		ll = t + 1
	else:
		rr = t


(n, k) = list(map(int, input().split()))
(l, r) = (1, n)
while l < r:
	m = (l + r) // 2
	s = m * (m + 1) // 2
	rem = n - m
	if s - rem == k:
		print(rem)
		exit()
	elif s - rem > k:
		r = m
	else:
		l = m
	if r - l == 1:
		break
s = l * (l + 1) // 2
rem = n - l
if s - rem == k:
	print(rem)
	exit()
rem = n - r
print(rem)


def sim(eat, n, post):
	nn = n - eat
	res = nn * (nn + 1) // 2
	return res - (post + eat)
(n, end) = map(int, input().split())
l = 0
r = n
i = 0
while True:
	i += 1
	if i > 100:
		print('lol')
	c = (r + l) // 2
	res = sim(c, n, end)
	if res == 0:
		print(c)
		break
	else:
		if res > 0:
			l = c
		if res < 0:
			r = c


def main():
	(n, k) = map(int, input().split())
	a = ((8 * (n + k) + 9) ** 0.5 - 3) / 2
	b = n - a
	print(int(b))
main()


(n, k) = list(map(int, input().split()))
l = (-3 + (9 + 4 * (2 * (n + k))) ** 0.5) // 2
print(int(n - l))


from math import *
(n, k) = map(int, input().split())
s = 1
dob = 2
for i in range(1, n):
	s += dob
	dob += 1
	if s - (n - i - 1) == k:
		print(n - i - 1)
		exit()
print(0)


(n, k) = map(int, input().split())
total = 1
c = 2
eat = 0
action = n - 1
while action:
	while total == 0 or total <= k:
		total += c
		c += 1
		action -= 1
	yy = total - k
	eat += yy
	action -= yy
	total -= yy
print(eat)


from math import *
(n, k) = list(map(int, input().split(' ')))
a = 1
b = -3 - 2 * n
c = n * n + n - 2 * k
x1 = (-b + sqrt(b ** 2 - 4 * a * c)) / (2 * a)
x2 = (-b - sqrt(b ** 2 - 4 * a * c)) / (2 * a)
x1 = int(x1)
x2 = int(x2)
if x1 < n and x1 >= 0:
	print(x1)
elif x2 < n and x2 >= 0:
	print(x2)


(n, k) = map(int, input().split())
(ok, ng) = (0, n)
while ng - ok > 1:
	mid = (ng + ok) // 2
	if (n - mid) * (n - mid + 1) // 2 - mid >= k:
		ok = mid
	else:
		ng = mid
print(ok)


x = list(map(int, input().split()))
start = 0
end = x[0] - 1
target = x[1]
ans = 0
while start <= end:
	mid = (start + end) // 2
	sum = mid * (mid + 1) // 2
	ans1 = x[0] - mid
	if sum - ans1 == target:
		ans = ans1
		break
	elif sum - ans1 > target:
		end = mid - 1
	else:
		start = mid + 1
print(ans)


from sys import stdin

def candy(n, k):
	(l, h) = (1, n)
	while l <= h:
		m = (l + h) // 2
		c = m * (m + 1) // 2
		x = c - (n - m)
		if x == k:
			return n - m
		elif x > k:
			h = m - 1
		elif x < k:
			l = m + 1
(n, k) = map(int, stdin.readline().split())
print(candy(n, k))


(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)
(move, can) = zz()
curr = 0
for i in range(1, move + 1):
	curr += i
	if curr - (move - i) == can:
		print(move - i)
		break
else:
	print(0)


(actions, candy) = map(int, input().split())
for i in range(actions + 1):
	if candy == i * (i + 1) / 2 - (actions - i):
		print(actions - i)
		break


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


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

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

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

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)

def print_list(l, delim=' '):
	print(delim.join(map(str, l)))
(n, e) = read_int_list()
print((2 * n + 3 - int(math.sqrt(8 * (n + e) + 9))) // 2)


import math
(n, k) = input().split()
n = int(n)
k = int(k)
s_o_r = 2 * n + 3
m_o_r = n * n + n - 2 * k
x1 = (s_o_r + math.sqrt(s_o_r * s_o_r - 4 * m_o_r)) // 2
x2 = (s_o_r - math.sqrt(s_o_r * s_o_r - 4 * m_o_r)) // 2
print(int(min(x1, x2)))


(n, k) = map(int, input().split())
b = 2 * (n + k)
l = 0
r = n

def check(x):
	return x ** 2 + 3 * x >= b
m = (l + r) // 2
while l != r:
	if check(m):
		r = m
	else:
		l = m + 1
	m = (l + r) // 2
print(n - m)


from math import sqrt
(n, k) = map(int, input().split())
a = 1
b = -1 * (2 * n + 3)
c = n * (n + 1) - 2 * k
res = -1 * b - sqrt(b * b - 4 * a * c)
res = res / 2
res = int(res)
print(res)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, k) = ria()
		a = 1
		b = -(2 * n + 3)
		c = n * (n + 1) - 2 * k
		x = (-b - int(math.sqrt(b ** 2 - 4 * a * c))) // (2 * a)
		print(x)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


(q, w) = map(int, input().split())
l = 0
r = q + 1
while l + 1 < r:
	m = (r + l) // 2
	if (1 + m) / 2 * m - (q - m) > w:
		r = m
	else:
		l = m
print(q - l)


(n, k) = map(int, input().split())
s = 0
i = 0
while s - (n - i) != k:
	i += 1
	s += i
print(n - i)


def solveEq(a, b, c):
	from math import sqrt
	delta = b ** 2 - 4 * a * c
	s1 = (-b + sqrt(delta)) / (2 * a)
	s2 = (-b - sqrt(delta)) / (2 * a)
	return (s1, s2)
(acao, final) = map(int, input().split())
a = 1
b = -2 * acao - 1 - 2
c = acao ** 2 + acao - 2 * final
(s1, s2) = solveEq(a, b, c)
ls = acao - s2
comeu = s2
soma = (ls + ls * ls) / 2
if soma - comeu == final:
	print(int(s2))
else:
	print(int(s1))


import math
line = input().split()
n = int(line[0])
k = int(line[1])
A = 1
B = 3
C = -2 * k - 2 * n
xo = (-B + int(math.sqrt(B * B - 4 * A * C))) // (2 * A)
yo = n - xo
print(yo)


(n, k) = map(int, input().rstrip().split())
last_add = 0
sum = 0
while sum - n != k:
	last_add += 1
	sum += last_add
	n -= 1
print(n)


(n, k) = map(int, input().split())
you = int(0)
cur_move = int(0)
cur = int(0)
while 1:
	if you == k + (n - cur_move):
		print(n - cur_move)
		break
	else:
		cur += 1
		you += cur
		cur_move += 1


(n, k) = map(int, input().split())
b = -3 - 2 * n
c = n * n + n - 2 * k
print(int((-b - (b ** 2 - 4 * c) ** (1 / 2)) // 2))


import math
a = input()
a = a.split(' ')
n = int(a[0])
k = int(a[1])
b = -(2 * n + 3)
delta = b * b - 4 * (n * n + n - 2 * k)
s_del = math.sqrt(delta)
x1 = (-b - s_del) / 2
x2 = (-b + s_del) / 2
print(int(min(x1, x2)))


from math import sqrt, floor
from sys import stdin
input = stdin.readline
(n, k) = [int(i) for i in input().split()]
print(floor((3 + 2 * n - sqrt((3 + 2 * n) ** 2 - 4 * (n ** 2 + n - 2 * k))) / 2))


import math
(n, k) = list(map(int, input().split()))
ans = -1 * math.sqrt(8 * k + 8 * n + 9) / 2 + n + 3 / 2
print(int(ans))


import math
import sys
from collections import deque

def scan() -> list:
	return list(map(int, sys.stdin.readline().strip().split()))

def solution() -> None:
	(n, k) = scan()
	print(round(n + 1.5 - math.sqrt(2 * (n + k) + 2.75)))
solution()


import collections
import random
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, s):
		pass

class Solution:

	def solve(self, n, k):
		grow = 1
		tot = 0
		while n != tot - k:
			tot += grow
			grow += 1
			n -= 1
		return tot - k
sol = Solution()
sol2 = Solution2()
for test_case in range(1):
	(N, K) = input().split()
	out = sol.solve(int(N), int(K))
	print(str(out))


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

def foo(n, eat):
	add = n - eat
	big_sum = add * (add + 1) / 2
	result = big_sum - eat
	return result
l = 0
r = n
while r - l >= 1:
	m = (r + l) // 2
	y = foo(n, m)
	if y > k:
		l = m + 1
	else:
		r = m
print(r)


(n, k) = [int(x) for x in input().split()]
d = 8 * (k + n) + 9
ans = d ** 0.5 - 3
ans //= 2
ans = n - ans
print(int(ans))


from math import sqrt
(n, k) = map(int, input().split())
w = sqrt(pow(2 * n + 3, 2) - 4 * (n ** 2 + n - 2 * k))
print(int((2 * n + 3 - w) // 2))


def solve():
	(n, k) = list(map(lambda x: int(x), input().split()))
	upper_bound = n + 1
	lower_bound = -1
	while upper_bound > lower_bound + 1:
		m = (upper_bound + lower_bound) // 2
		if (n - m) * (n - m + 1) // 2 - m > k:
			lower_bound = m
		else:
			upper_bound = m
	print(upper_bound)
solve()


import math
f = input()
z = f.split()
m = int(z[0])
n = int(z[1])
m1 = (-3 + math.sqrt(9 + 8 * (n + m))) / 2
print(int(m - m1))


(n, k) = input().split()
n = int(n)
k = int(k)
low = -1
high = n + 1
while high - low > 1:
	mid = (low + high) // 2
	if (n - mid) * (n - mid + 1) // 2 - mid > k:
		low = mid
	else:
		high = mid
print(high)


def bS_sol(l, r, n, k):
	while r - l > 1:
		m = (r + l) // 2
		X = n - m
		if X * (X + 1) / 2 - m > k:
			l = m
		else:
			r = m
	print(r)
(n, k) = map(int, input().split())
bS_sol(-1, n + 1, n, k)


from math import sqrt
(n, k) = list(map(int, input().split()))
print(int(n - 0.5 * (sqrt(8 * (k + n) + 9) - 3)))


(n, k) = map(int, input().split())
x = 0
n1 = n // 2
n1 = n1 + 1
if n == 1:
	if k == 1:
		print(0)
else:
	p = n * (n + 1) // 2
	if p == k:
		print(0)
	else:
		for i in range(1, n + 1):
			p = i * (i + 1) // 2
			if p - k == n - i:
				print(p - k)
				quit()


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
l = 1
r = n
while l <= r:
	mid = l + (r - l) // 2
	res = mid * (mid + 1) // 2 - (n - mid)
	if res == k:
		stdout.write(f'{n - mid}\n')
		break
	elif res > k:
		r = mid - 1
	else:
		l = mid + 1


import math as m
(a, b) = map(int, input().split())
print(int((2 * a + 3 - m.sqrt(8 * a + 8 * b + 9)) // 2))


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
(n, k) = ri()
ans = 0
x = 1

def get(x):
	return x * (x + 1) // 2
for i in range(10 ** 5):
	if get(i) == k + n - i:
		ans = n - i
		break
print(ans)


from sys import *
from math import *
(n, k) = map(int, stdin.readline().split())
f = 0
for i in range(1, n + 1):
	x = i * (i + 1) // 2
	if k + n - i == x:
		f = 1
		break
print(n - i)


(n, k) = map(int, input().split())
l = 0
r = n
while l <= r:
	mid = l + (r - l) // 2
	if mid * (mid + 1) // 2 - k + mid == n:
		print(mid * (mid + 1) // 2 - k)
		break
	elif mid * (mid + 1) // 2 - k + mid > n:
		r = mid - 1
	else:
		l = mid + 1


def binarySearch(N, l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		Temp = mid * (mid + 1) // 2
		if Temp - x == N - mid:
			return N - mid
		elif Temp - x > N - mid:
			return binarySearch(N, l, mid - 1, x)
		else:
			return binarySearch(N, mid + 1, r, x)
	else:
		return -1
(n, k) = list(map(int, input().split()))
print(binarySearch(n, 0, n, k))


(n, k) = [int(i) for i in input().split()]
from math import sqrt
d = 9 + 8 * (n + k)
nb_mange = (-3 + int(sqrt(d))) / 2
print(int(n - nb_mange))


(n, left) = map(int, input().split())
if n == 1:
	print(0)
else:
	for i in range(1, n + 1):
		added = i * (i + 1) // 2
		eaten = n - i
		if added - eaten == left:
			print(eaten)
			break


(n, k) = map(int, input().split())
l = 0
r = n - 1
c = 0
while l <= r:
	m = (l + r) // 2
	a = m * (m + 1) // 2
	b = n - m
	if a - b == k:
		c = b
		break
	elif a - b > k:
		r = m - 1
	else:
		l = m + 1
print(c)


from sys import stdin

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

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

def linput():
	return list(map(int, stdin.readline().split()))
(n, k) = minput()
(l, r) = (0, n)
while l < r:
	mid = (l + r) // 2
	if (n - mid) * (n - mid + 1) // 2 - mid == k:
		print(mid)
		break
	elif (n - mid) * (n - mid + 1) // 2 - mid > k:
		l = mid
	else:
		r = mid


left = -1
right = 10000000000.0 - 1
nn = [int(i) for i in input().split()]
n = nn[0]
k = nn[1]
f = True
while right - left > 1:
	mid = (left + right) // 2
	if (n - mid + 1) * abs(n - mid) // 2 - mid > k:
		left = mid
	elif (n - mid + 1) * abs(n - mid) // 2 - mid == k:
		print(round(mid))
		f = False
		break
	else:
		right = mid
if f:
	print(round(left))


def binary_search(n, low, high, k):
	index = 0
	while low <= high:
		mid = (low + high) // 2
		if mid * (mid + 1) // 2 - k == n - mid:
			return mid
		elif mid * (mid + 1) // 2 - k > n - mid:
			high = mid - 1
		else:
			low = mid + 1
	return index
(n, k) = map(int, input().split())
print(n - binary_search(n, 0, n, k))


from sys import stdin, stdout
import math

def mm(x):
	val = math.sqrt(9 + 8 * x)
	val = int(val)
	val -= 3
	return val // 2

def meth(x):
	n = mm(x)
	return n * (n + 1) // 2
(n, k) = list(map(int, stdin.readline().split()))
val = meth(n + k)
print(val - k)


import math
(n, k) = map(int, input().split())
x = (math.pow(9 + 8 * n + 8 * k, 1 / 2) - 3) // 2
y = n - x
print(int(y))


import sys
import math
input = sys.stdin.readline
(n, k) = map(int, input().split())
ans = -1
for i in range(int(math.sqrt(2 * (n + k)))):
	if i * (i + 3) // 2 == n + k:
		ans = n - i
print(ans)


import math
(n, k) = map(int, input().split())
a = 1
b = -2 * n - 3
c = n * n - 2 * k + n
d = -4 * a * c + b * b
x1 = (-b + math.sqrt(d)) / (2 * a)
x2 = (-b - math.sqrt(d)) / (2 * a)
if x2 >= 0 and x1 <= n:
	print(int(x1))
if x2 >= 0 and x2 <= n:
	print(int(x2))


(n, k) = map(int, input().split())
t = 0
for i in range(1, n + 1):
	x = i * (i + 1) // 2
	if x >= k:
		t = i
		break
for i in range(t, n + 1):
	x = i * (i + 1) // 2
	y = x - k
	if i + y == n:
		print(y)
		break


def func(x):
	global n
	y = n - x
	return y * (y + 1) // 2 - x
(n, k) = map(int, input().split())
l = -1
r = n + 1
while r - l > 1:
	m = (l + r) // 2
	if func(m) > k:
		l = m
	else:
		r = m
if func(l) == k:
	print(l)
elif func(r) == k:
	print(r)
else:
	print(l, r, func(l), func(r))


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

def split_k(x):
	t = x + 1
	addition = t * (t + 1) // 2
	return (addition - (n - x - 1) - k, n - x - 1)
j = 0
while split_k(j)[0] != 0:
	j += 1
print(split_k(j)[1])


import math
s = input()
s = s.split()
n = int(s[0])
k = int(s[1])
b = 2 * n + 3
c = 4 * (n * n + n - 2 * k)
if b * b - c >= 0:
	d = int(math.sqrt(b * b - c))
	p = int((b + d) / 2)
	q = int((b - d) / 2)
	if p >= 0 and p < n:
		print(p)
	elif q >= 0 and q < n:
		print(q)


(n, k) = [int(x) for x in input().split(' ')]
sum = 0
j = 0
for i in range(1, n + 1):
	sum = sum + i
	if sum - n + i == k:
		print(n - i)
		break


(n, k) = map(int, input().split())
(b, c, a) = (0, 1, 0)
while n > 0:
	if b > k:
		d = min(n, b - k)
		a += d
		b -= d
		n -= d
	else:
		b += c
		c += 1
		n -= 1
print(a)


(n, k) = map(int, input().split(' '))
a = 2 * n + 3
b = (8 * n + 8 * k + 9) ** 0.5
x = a - b
x = x // 2
print(int(x))


import sys
inf = sys.maxsize
(n, k) = map(int, input().split())
for i in range(1, n + 1):
	temp = i * (i + 1) // 2
	if temp - (n - i) == k:
		print(n - i)
		break


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
from math import sqrt

def fun(n, k):
	x = sqrt(8 * (n + k) + 9)
	y = 3 + 2 * n
	return ((y + x) // 2, (y - x) // 2)
(n, k) = lin()
(i, j) = fun(n, k)
print(int(j))


candies = 0
(n, k) = map(int, input().split())
summ = 0
if k == 0:
	for i in range(n - 1, -1, -1):
		summ = summ + 1
		candies = candies + summ
		if candies == i:
			print(i)
			break
if k != 0:
	for i in range(n - 1, -1, -1):
		summ = summ + 1
		candies = candies + summ
		if candies - i == k:
			print(i)
			break


from math import sqrt
(n, k) = map(int, input().split())
print(n - int(-1.5 + sqrt(9 / 4 + 2 * (k + n))))


import math
(n, k) = map(int, input().split(' '))
h = int((-3 + math.sqrt(9 + 8 * (n + k))) // 2)
out = n - h
print(out)


(n, k) = map(int, input().split())
left = 0
right = n
while left <= right:
	mid = (left + right) // 2
	adds = mid * (mid + 1) // 2
	eats = n - mid
	if adds - eats == k:
		print(eats)
		break
	elif adds - eats > k:
		right = mid - 1
	else:
		left = mid + 1


import math
(n, k) = list(map(int, input().split()))
x = math.ceil((-1 + math.sqrt(1 + 8 * k)) / 2)
while x * (x + 1) / 2 - n + x != k:
	x += 1
print(n - x)


import math
m = input().split()
n = int(m[0])
k = int(m[1])
c = (n + k) * 2
print(int(n - (-3 + math.sqrt(9 + 4 * c)) / 2))


def check(n, k):
	return n * (n + 1) // 2 - k
(n, k) = map(int, input().split())
l = 0
r = 10 ** 10
while l <= r:
	mid = (l + r) // 2
	if check(mid, k) + mid > n:
		r = mid - 1
	elif check(mid, k) + mid < n:
		l = mid + 1
	else:
		print(check(mid, k))
		exit()


def main():
	import sys
	input = sys.stdin.readline
	(n, k) = map(int, input().split())
	l = 1
	r = n + 1
	while r - l != 1:
		m = l + r >> 1
		candies = m * (m + 1) // 2
		eat = n - m
		if candies - eat <= k:
			l = m
		else:
			r = m
	print(n - l)
	return 0
main()


def main():
	[n, k] = list(map(int, input().split()))
	for i in range(n + 1):
		if i * (i + 1) / 2 - (n - i) == k:
			print(n - i)
			break
main()


import math
nk = input()
nk = nk.split()
n = int(nk[0])
k = int(nk[1])
m = int(-1 + math.sqrt(1 + 8 * k) / 2)
val = m * (m + 1) / 2
if val < k:
	m += 1
ate1 = n - m
ate2 = m * (m + 1) / 2 - k
while ate1 != ate2:
	m += 1
	ate1 = n - m
	ate2 = m * (m + 1) / 2 - k
print(ate1)


import sys
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
(n, k) = intInp()
candy = 1
achived = 0
for i in range(1, n + 1):
	achived += candy
	if achived - (n - i) == k:
		print(n - i)
		break
	candy += 1


a = list((int(x) for x in input().split()))
actions = a[0]
candies_left = a[1]
for i in range(0, a[0] + 1):
	if i * (i + 1) // 2 == actions + candies_left - i:
		print(actions - i)
		break
	else:
		continue


from math import sqrt
(n, k) = map(int, input().split())
x = 2 * n + 3
y = n * (n + 1)
s = (x - sqrt(x * x - 4 * (y - 2 * k))) // 2
print(int(s))


(n, k) = map(int, input().split())
for i in range(100000):
	put = i
	eat = n - i
	pc = (1 + i) * i // 2
	if pc - eat == k:
		print(eat)
		break


import math
(n, k) = map(int, input().split())
a = 1
b = -1
c = -2 * (n + k)
d = b ** 2 - 4 * a * c
x = (-b - math.sqrt(d)) / (2 * a)
y = (-b + math.sqrt(d)) / (2 * a)
if x > y:
	print(abs(int(x) - n - 1))
else:
	print(abs(int(y) - n - 1))


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

def sumTillN(n):
	return n * (n + 1) // 2
minEat = 0
maxEat = n
midEat = 0
while minEat <= maxEat:
	midEat = (minEat + maxEat) // 2
	x = sumTillN(n - midEat)
	if x == k + midEat:
		break
	elif x > k + midEat:
		minEat = midEat + 1
	else:
		maxEat = midEat - 1
print(midEat)


import sys
inf = float('inf')

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()
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
(n, k) = get_ints()
if k == 0:
	d1 = 1 + 8 * n
	ans = floor((-1 + sqrt(d1)) / 2)
	new_ans = ans * (ans + 1) // 2
	print(new_ans)
	quit()
d2 = 1 + 8 * k
ans1 = ceil((-1 + sqrt(d2)) / 2)
chance = n - ans1
while ans1 * (ans1 + 1) // 2 - chance < k:
	chance -= 1
	ans1 += 1
print(chance)


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


(n, k) = map(int, input().split())
bank = 1
count = 0
j = 1
n -= 1
while n > 0:
	if bank <= k:
		j += 1
		bank += j
		n -= 1
	else:
		while bank > k:
			n -= 1
			bank -= 1
			count += 1
print(count)


(n, k) = map(int, input().split())
for r in range(1, 10 ** 5):
	if r * (r + 1) // 2 + r == k + n:
		print(n - r)
		exit()


from sys import stdin
from math import sqrt
(n, k) = map(int, stdin.readline().split())
print(n - round((sqrt(9 + 8 * (n + k)) - 3) // 2))


def find(n, k):
	x = 9 + 8 * (n + k)
	a = (-3 + int(x ** 0.5)) // 2
	b = n - a
	return b
(n, k) = list(map(int, input().strip().split(' ')))
print(find(n, k))


from sys import stdin
(actions, final) = (int(i) for i in stdin.readline().split())
print(actions - int((2 * (actions + final)) ** 0.5) + 1)


from collections import Counter
(n, k) = map(int, input().split())
for p in range(n + 1):
	if p * (p + 1) // 2 - (n - p) == k:
		print(n - p)
		break


(n, k) = map(int, input().split())
print(round(n + 1.5 - (2 * (n + k) + 2.75) ** 0.5))


def search(i, n, m):
	s = i * (i + 1) // 2
	left = n - i
	if s - left > m:
		return 1
	elif s - left < m:
		return -1
	else:
		return 0
from collections import defaultdict as dc
(n, m) = [int(i) for i in input().split()]
i = 0
p = 1
s = 0
l = 1
r = n
while l <= r:
	mid = (l + r) // 2
	ans = search(mid, n, m)
	if ans == 0:
		break
	elif ans == 1:
		r = mid
	else:
		l = mid
left = n - mid
print(left)


(n, k) = [int(item) for item in input().split()]
candy = 0
add = 0
for i in range(0, 10 ** 5):
	candy += add
	add += 1
	if candy - k == n - i:
		print(n - i)
		exit()


(n, k) = map(int, input().split())
d = int((9 + 8 * (n + k)) ** 0.5)
x = (d - 3) // 2
print(n - x)


(n, k) = map(int, input().split())
D = 8 * (k + n) + 9
D = D ** 0.5
ans = (2 * n + 3 - D) // 2
print(int(ans))


import math
(n, k) = list(map(int, input().split(' ')))
l = (math.sqrt(9 + 8 * (n + k)) - 3) // 2
print(int(n - l))


import sys
import os.path
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, m) = map(int, input().split())
(cnt, sum, ans) = (2, 1, 0)
while n > 0:
	if sum > m:
		ans = ans + sum - m
		n = n - (sum - m)
		sum = m
	else:
		sum = sum + cnt
		n = n - 1
		cnt = cnt + 1
print(ans)


args = input().split()
n = int(args[0])
k = int(args[1])
candies = 0
steps = 0
s = 1
for i in range(n):
	steps += 1
	candies += s
	s += 1
	if candies - (n - steps) == k:
		print(n - steps)
		break


(n, k) = map(int, input().split())
s = 0
ans = 0
t = 0
flag = 0
for i in range(1, n + 1):
	t += i
	if t > k:
		if t - k == n - i:
			ans = n - i
			flag = 1
	if flag:
		break
print(ans)


R = lambda : map(int, input().split())
(n, k) = R()
(l, h) = (0, n)
while l <= h:
	m = l + h >> 1
	p = m * (3 + m) // 2
	if p == n + k:
		print(n - m)
		quit()
	elif p > n + k:
		h = m - 1
	else:
		l = m + 1


(n, k) = map(int, input().split())
l = 0
r = n
while l <= r:
	m = (l + r) // 2
	val = m * (m + 1) // 2 - (n - m)
	if k == val:
		print(n - m)
		exit()
	elif k > val:
		l = m + 1
	else:
		r = m - 1


def sos(n):
	return n * (n + 1) // 2
(n, k) = map(int, input().split())
(l, h, m, a) = (0, n, 0, 0)
while l <= h:
	m = (l + h) // 2
	if sos(m) - (n - m) == k:
		a = n - m
		break
	elif sos(m) - (n - m) < k:
		l = m + 1
	else:
		h = m - 1
print(a)


(n, m) = list(map(int, input().split()))
for i in range(1, n + 1):
	j = i * (i + 1) // 2
	if j >= m:
		if j == m and i == n:
			print(0)
			break
		else:
			t = n - i
			if j - t == m:
				print(t)
				break
			elif j - t < m:
				continue


def f(n):
	return n * (n + 3) // 2
(n, k) = list(map(int, input().split()))
low = 0
high = n + k
ans = low
while low <= high:
	mid = (low + high) // 2
	if f(mid) == k + n:
		ans = mid
		break
	elif f(mid) > k + n:
		high = mid - 1
	else:
		low = mid + 1
print(n - ans)


import math
(n, k) = [int(x) for x in input().split()]
discriminant = 9 + 8 * (k + n)
if n != 1:
	print(n - int((-3 + math.sqrt(discriminant)) / 2))
else:
	print(0)


import sys
(n, k) = [int(i) for i in sys.stdin.readline().split()]
left = 0
right = n - 1
while left <= right:
	mid = left + (right - left) // 2
	fmid = (mid + 1) * (mid + 2) / 2 - (n - (mid + 1))
	if fmid == k:
		print(n - 1 - mid)
	if fmid > k:
		right = mid - 1
	else:
		left = mid + 1


temp = input().split()
n = int(temp[0])
k = int(temp[1])

def count(n2):
	return (n - n2) / 2 + (n - n2) ** 2 / 2 - n2
l_b = 0
u_b = n
g = (u_b + l_b) // 2
probe = count(g)
while probe != k:
	if probe < k:
		u_b = g
	else:
		l_b = g
	g = (u_b + l_b) // 2
	probe = count(g)
print(int(g))


import time
(n, k) = (int(i) for i in input().split())
start = time.time()
print((2 * n + 3 - int((9 + 8 * (n + k)) ** 0.5)) // 2)
finish = time.time()


arr = [int(i) for i in filter(None, input().split(' '))]
k_hodov = arr[0]
konf = arr[1]
left = 0
right = k_hodov + 100
while right - left > 1:
	mid = (right + left) // 2
	k_give = k_hodov - mid
	if (k_give + 1) * (k_give / 2) // 1 - mid < konf or k_give < 0:
		right = mid
	else:
		left = mid
k_give = k_hodov - left
if (k_give + 1) * (k_give / 2) // 1 - left == konf:
	print(left)
else:
	print(left - 1)


(n, k) = [int(x) for x in input().split()]
import math as m
l = 8 * (n + k)
t = -3 + m.sqrt(9 + l)
a = t / 2
print(int(n - a))


(n, x) = map(int, input().split())
formula = 0
i = 0
if n == 1:
	print(0)
else:
	formula = 1000000
	while abs(n - (i + formula)) != x:
		i = i + 1
		formula = i * (i + 1) // 2
	print(abs(n - i))


import sys
(n, k) = sys.stdin.readline().split()
n = int(n)
k = int(k)
l = 0
r = n
while l < r:
	m = int((l + r) / 2)
	if (n - m) * (n - m + 1) / 2 - m == k:
		print(m)
		break
	if (n - m) * (n - m + 1) / 2 - m > k:
		l = m
	else:
		r = m


import math
(n, k) = map(int, input().split())
result1 = 2 * n + 3
result2 = math.sqrt(math.pow(2 * n + 3, 2) - 4 * (n * (n + 1) - 2 * k))
print(int(round((result1 - result2) / 2)))


import math
import sys

def minPut(n):
	return math.ceil((-1 + math.sqrt(1 - 4 * (-n * 2))) / 2)

def nCandies(n):
	return int(n * (n + 1) / 2)
(actions, candies) = map(int, sys.stdin.readline().split())
put = minPut(candies)
putCandies = nCandies(put)
eat = putCandies - candies
while put + eat < actions:
	eat += put + 1
	put += 1
print(eat)


(n, k) = map(int, input().split())
i = 1
s = 0
while i <= n:
	s = s + i
	if s - k >= 0 and s - k == n - i:
		print(n - i)
		break
	i += 1


import math

def calc(x):
	if x == 1:
		return 1
	else:
		return (1 + x) * x / 2

def main():
	(x, left) = map(int, input().split())
	if x == 1 and left == 1:
		print(0)
	else:
		l = 1
		r = x
		while True:
			if r - l <= 1:
				result = calc(l)
				if result - (x - l) == left:
					print(x - l)
					break
				result = calc(r)
				if result - (x - r) == left:
					print(x - r)
					break
				print(l, r)
				break
			mid = math.floor((l + r) / 2)
			result = calc(mid)
			if result - (x - mid) == left:
				print(x - mid)
				break
			elif result - (x - mid) > left:
				r = mid
			elif result - (x - mid) < left:
				l = mid
main()


import math
(n, k) = map(int, input().split())
p1 = (-3 + math.sqrt(9 + 8 * (n + k))) / 2
p2 = (-3 - math.sqrt(9 + 8 * (n + k))) / 2
if p1 >= 0 and p2 >= 0:
	if p1 <= n:
		print(int(n - p1))
	else:
		print(int(n - p2))
else:
	print(int(n - max(p1, p2)))


(n, k) = map(int, input().split())
l = 0
h = n
while l <= h:
	mid = (h + l) // 2
	num = (n - mid) * (n - mid + 1) // 2 - mid
	if num == k:
		print(mid)
		exit(0)
	elif num > k:
		l = mid + 1
	else:
		h = mid - 1


nk = list(map(int, input().split()))
sweets = [1]
while sweets[-1] < nk[1] or len(sweets) + sweets[-1] - nk[1] != nk[0]:
	sweets.append(sweets[-1] + len(sweets) + 1)
print(sweets[-1] - nk[1])


(n, k) = map(int, input().split())
c = 2 * (n + k)
l = (-3 + (9 + 4 * c) ** 0.5) / 2
m = n - int(l)
print(m)


def sport_mafia():
	candys = list(map(int, input().split()))
	if candys[0] == 1:
		return 0
	in_box = 0
	for i in range(1, candys[0] + 1):
		in_box += i
		if in_box - (candys[0] - i) == candys[1]:
			return candys[0] - i
A = sport_mafia()
print(A)


def main():
	s = input()
	n = int(s.split()[0])
	k = int(s.split()[1])
	s = 0
	for i in range(n + 1):
		s += i
		if s - n + i == k:
			return n - i
print(main())


(n, k) = list(map(int, input().split()))
ans = n + k
if n == 1:
	print(0)
for i in range(n):
	if ans == i * (i + 1) / 2 + i:
		print(n - i)
		break


(n, k) = input().split()
n = int(n)
k = int(k)
inc_step = 1
sum = 1
i = 1
while n - inc_step:
	inc_step += 1
	i += 1
	sum += i
	if sum - k == n - inc_step:
		break
print(n - inc_step)


import math
line1 = list(map(int, input().split()))
n = line1[0]
k = line1[1]
delta = 9 + 4 * ((n + k) * 2)
element = int(math.sqrt(delta))
x1 = (-3 + element) // 2
x2 = (-3 - element) // 2
if x1 >= 0:
	non_ate_moves = x1
else:
	non_ate_moves = x2
print(n - non_ate_moves)


(n, k) = map(int, input().split())
if n == 1:
	print(0)
	exit()
cnt = 1
i = 2
step = 1
ans = 0
while step <= n:
	if cnt > k:
		ans += min(cnt - k, n - step)
		step += cnt - k
		cnt = k
	cnt += i
	step += 1
	i += 1
print(ans)


can = lambda n, e: (n - e + 1) * (n - e) // 2 - e
(n, k) = map(int, input().split())
a = 0
for i in range(len(bin(n)) - 3, -1, -1):
	if a + 2 ** i < n and can(n, a + 2 ** i) >= k:
		a += 2 ** i
print(a)


(n, k) = map(int, input().split())
if n == 1:
	print('0')
else:
	c = int(-(2 * k - n * n - n))
	b = -(2 * n + 3)
	d = b * b - 4 * c
	r1 = (-b + d ** 0.5) / 2
	r2 = (-b - d ** 0.5) / 2
	if type(r1) != complex():
		if r1 < n:
			print(int(r1))
	if type(r2) != complex():
		if r2 < n:
			print(int(r2))


import math

def root(b, c):
	a = 1
	d = b ** 2 - 4 * a * c
	sol1 = (-b - math.sqrt(d)) / (2 * a)
	sol2 = (-b + math.sqrt(d)) / (2 * a)
	return [int(sol1), int(sol2)]
(n, k) = map(int, input().split())
l = root(-3 - 2 * n, n ** 2 + n - 2 * k)
for x in l:
	if x < n:
		print(x)
		exit(0)


import math as m
(n, k) = map(int, input().split())
p = (int(m.sqrt(9 + 8 * (k + n))) - 3) // 2
print(n - p)


from math import ceil
(n, k) = map(int, input().split())
for i in range(1, n + 1):
	if i * (i + 1) / 2 - (n - i) == k:
		print(n - i)
		break


import math
(a, b) = map(int, input().split())
c = 2 * (a + b)
x = (-3 + math.sqrt(9 + 4 * c)) / 2
print(math.ceil(a - x))


import math
inp = input().split()
n = int(inp[0])
k = int(inp[1])
if n == 1 and k == 0:
	print('1')
elif n == 1 and k == 1:
	print('0')
else:
	b1 = 0.5 * (2 * n + 3 + math.sqrt(8 * n + 8 * k - 9))
	b2 = 0.5 * (2 * n + 3 - math.sqrt(8 * n + 8 * k - 9))
	if min(b1, b2) > 0:
		print(int(min(b1, b2)))
	else:
		print(int(max(b1, b2)))


import sys
arr = input()
arr1 = ''
arr2 = ''
for i in arr:
	if i == ' ':
		break
	arr1 += i
flag = 0
for i in arr:
	if flag == 1:
		arr2 += i
	if i == ' ':
		flag = 1
a = 0
b = 0
for i in arr1:
	a = a * 10 + int(i)
for i in arr2:
	b = b * 10 + int(i)
print(int(a - ((9 + 8 * b + 8 * a) ** 0.5 - 3) / 2))


(n, k) = tuple([int(x) for x in input().split()])
l = 0
u = n
best = -1
while l <= u:
	m = (l + u) // 2
	if m * (m + 1) // 2 - (n - m) >= k:
		best = m
		u = m - 1
	else:
		l = m + 1
print(n - best)


(n, k) = map(int, input().split())
(l, r) = (0, 10 ** 15)
while l + 1 < r:
	mid = (l + r) // 2
	if (1 + mid) * mid / 2 - (n - mid) > k:
		r = mid
	else:
		l = mid
print(n - l)


import math
(n, k) = map(int, input().split())
print(int(n + 1.5 - (2.25 + 2 * (n + k)) ** 0.5))


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


import math
(n, k) = map(int, input().split(' '))
delta = (2 * n + 3) ** 2 - 4 * (n * (n + 1) - 2 * k)
if delta == 0:
	print((-2 * n - 3) / 2)
elif (2 * n + 3 + math.sqrt(delta)) / 2 < n:
	print(int((2 * n + 3 + math.sqrt(delta)) / 2))
else:
	print(int((2 * n + 3 - math.sqrt(delta)) / 2))


(n, k) = map(int, input().split())
current = 0
eaten = None
for i in range(1, n + 1):
	current += i
	if current == k + (n - i):
		eaten = n - i
		break
if eaten is not None:
	print(eaten)
else:
	raise ValueError('n == {}, k == {}, eaten == {}, current == {}'.format(n, k, eaten, current))


import math
(n, k) = map(int, input().split())
ans = n - math.sqrt(2 * (k + n) + 9 / 4) + 3 / 2
print(int(ans))


import math
from sys import stdin, stdout
input = stdin.readline
(n, k) = list(map(int, input().split()))
if n == 1:
	print(0)
elif n == 2:
	if k == 0:
		print(1)
	else:
		print(0)
else:
	d = 9 + 4 * (2 * n + 2 * k)
	p = (-3 + math.sqrt(d)) // 2
	print(n - int(p))


(N, K) = map(int, input().split())
B = -2 * N - 3
C = N * N + N - 2 * K

def sqr(n):
	x = n
	y = (x + 1) // 2
	while y < x:
		x = y
		y = (x + n // x) // 2
	return x
t = sqr(B * B - 4 * C)
print((-B - t) // 2)


a = list(map(int, input().split()))
n = a[0]
k = a[1]
y = 2 * n + 3
x = 8 * n + 8 * k + 9
s = y - x ** (1 / 2)
print(int(s / 2))


import re
s = input()
d = re.findall('\\d+', s)
n = int(d[0])
k = int(d[1])
solution = int((3 + 2 * n - (9 + 8 * n + 8 * k) ** (1 / 2)) / 2)
print(solution)


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


import math
S = input()
n = int(S[0:S.find(' ')])
k = int(S[S.find(' ') + 1:len(S)])
sweet = 0
turns = 0
pl = 1
ans = 0
while turns != n:
	turns += 1
	if sweet < k:
		sweet += pl
		pl += 1
	else:
		sweet -= 1
		ans += 1
print(ans)


import math
(m, k) = map(int, input().strip().split())
if m == 1 and k == 1:
	print(0)
else:
	x = (-3 + math.sqrt(9 + 8 * (m + k))) / 2
	print(int(m - x))


import math

def valid(n, k, c1, c2):
	if c1 > n:
		return c2
	elif c2 > n:
		return c1
	ans_one = (n - c1) * (n - c1 + 1) // 2 - c1
	if ans_one == k:
		return c1
	return c2

def f(n, k):
	b2 = 2 * n + 3
	delta = int(math.sqrt(8 * n + 8 * k + 9))
	return valid(n, k, (b2 + delta) // 2, (b2 - delta) // 2)
(n, k) = map(int, input().strip().split(' '))
print(f(n, k))


(n, k) = [int(x) for x in input().split()]
c = 1
for i in range(1, n + 1):
	a = n - i
	if a == c - k:
		break
	c += i + 1
print(a)


line = input().split()
n = int(line[0])
k = int(line[1])
x = 2 * n + 3 - ((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)) ** 0.5
print(int(x / 2))


(n, k) = map(int, input().split())
banka = 0
set_sweet = 0
get_sweet = 0
i = 0
while i < n:
	if banka <= k or banka == 0:
		set_sweet += 1
		banka += set_sweet
		i += 1
	else:
		i += banka - k
		get_sweet += banka - k
		banka -= banka - k
print(get_sweet)


(n, k) = map(int, input().split())
l = -1
r = n + 1
while r - l > 1:
	m = (l + r) // 2
	t = m * (m + 1) // 2
	t -= n - m
	if t > k:
		r = m
	else:
		l = m
print(l * (l + 1) // 2 - k)


class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

	@staticmethod
	def calc(sep='', k=''):
		count = 0
		for i in range(sep):
			j = sep - i
			sum = (i + 1) * i / 2
			if sum - j == k:
				return j
		return count

def main():
	(n, k) = Read.list_int()
	print(Read.calc(n, k))
main()


nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
sm = 1
ans = 0
for i in range(2, n + 1):
	sm += i
	if sm - (n - i) == k:
		ans = n - i
		break
print(ans)


(n, c) = [int(p) for p in input().split()]
root = ((9 + 8 * (n + c)) ** 0.5 - 3) / 2
print(n - int(root))


import math
(n, k) = map(int, input().split())
c = 2 * (k + n)
s = math.sqrt(9 + 4 * c)
ans2 = (-3 + s) // 2
ans = (-3 - s) // 2
print(n - int(max(ans, ans2)))


(n, k) = map(int, input().split())
for puts in range(10 ** 9):
	candy = puts * (puts + 1) // 2
	if candy - (n - puts) == k:
		print(n - puts)
		exit(0)


(n, k) = map(int, input().split())
a = 1
b = n
if n == 1:
	print(0)
else:
	while a <= b:
		x = a + (b - a) // 2
		can = (1 + n - x) * (n - x) // 2 - x
		if can == k:
			print(x)
			break
		if can > k:
			a = x + 1
		else:
			b = x - 1


import math
(n, k) = input().split(' ')
n = int(n)
k = int(k)
c = 2 * (n + k)
y = (-3 + math.sqrt(9 + 4 * c)) / 2
x = n - y
x = int(x)
print(x)


data = list(map(int, input().split()))
sum = 0
cont = 0
res = 0
con2 = 0
con3 = 0
for i in range(data[0]):
	sum = sum + con2
	con2 += 1
	res = data[0] - con2
	if data[1] == 0:
		if sum >= res:
			cont += 1
	elif sum > data[1]:
		if res + 1 == sum - data[1]:
			cont = res + 1
			break
print(cont)


import sys
(n, k) = map(int, sys.stdin.readline().split())
print(int(n - ((9 + 8 * k + 8 * n) ** 0.5 - 3) / 2))


(n, k) = map(int, input().split())
print(n + 1 - int(((k + n + 1) * 200 + 25) ** 0.5) // 10)


from collections import defaultdict
from math import sqrt
t = 1
for test in range(t):
	(n, k) = map(int, input().split())
	ans = -3
	ans += int(sqrt(9 + 8 * k + 8 * n))
	ans = ans // 2
	print(n - ans)


def main():
	(n, k) = map(int, input().split())
	start = 0
	end = n
	while start <= end:
		m = (start + end) // 2
		sum = m * (m + 1) // 2
		if sum - abs(n - m) > k:
			end = m - 1
		elif sum - abs(n - m) < k:
			start = m + 1
		else:
			print(n - m)
			break
main()


def func():
	(n, k) = map(int, input().strip().split())
	l = 0
	r = n
	while l <= r:
		mid = (l + r) // 2
		if mid * (mid + 1) / 2 - (n - mid) < k:
			l = mid + 1
		elif mid * (mid + 1) / 2 - (n - mid) > k:
			r = mid
		else:
			print(n - mid)
			return mid
func()


import math
(n, k) = list(map(int, input().strip().split()))
b = 2 * n + 3
c = n * n + n - 2 * k
print(int((b - math.sqrt(b * b - 4 * c)) // 2))


(n, k) = map(int, input().split())
S = -n
j = 1
a = n
while S != k:
	S += 1 + j
	j += 1
	a -= 1
print(a)


X = list(map(int, input().split()))
if X[0] == 1 or X[0] * (X[0] + 1) // 2 == X[1]:
	print(0)
	exit()
i = 1
while X[0] - i + X[1] != i * (i + 1) // 2:
	i += 1
print(X[0] - i)


(moves, candies) = map(int, input().split())
import math
print(int(moves - (-3 + math.sqrt(9 + 8 * (moves + candies))) // 2))


def binarysearch(l, r, val, n):
	if r >= l:
		mid = l + (r - l) // 2
		a = (mid + 1) * (mid + 2) / 2 - (n - mid + 1)
		if a == val:
			return mid
		elif a > val:
			return binarysearch(l, mid - 1, val, n)
		else:
			return binarysearch(mid + 1, r, val, n)
	return r + 1
(n, k) = map(int, input().split())
z = binarysearch(0, n - 1, k, n)
print(n - z)


(n, k) = map(int, input().split())
a = int((2 * (n + k)) ** 0.5)
found = False
while not found:
	if a * (a + 3) == 2 * (n + k):
		found = True
	else:
		a -= 1
print(n - a)


(n, k) = map(int, input().split())
lo = 1
hi = n
ans = 0
while lo < hi:
	mid = lo + hi >> 1
	candies = mid * (mid + 1) >> 1
	eat = n - mid
	rem = candies - eat
	if k == rem:
		ans = eat
		break
	elif k < rem:
		hi = mid
	else:
		lo = mid
print(ans)


(n, k) = map(int, input().split())
step = 1
cnt = 1
for i in range(100000):
	sum = cnt * (cnt + 1) / 2
	if sum - (n - step) == k:
		print(n - step)
		break
	step += 1
	cnt += 1


s = input().rstrip().split()
N = int(s[0])
K = int(s[1])
RHS = 2 * (N + K) + 9 / 4
sqrtRHS = RHS ** 0.5
print(N - round(sqrtRHS - 1.5))


import math
(no_of_moves, no_of_candy) = map(int, input().split())
total_candy = now_candy = 1
now_moves = 1
if no_of_moves == 0 or (no_of_moves == 1 and no_of_candy == 1):
	print(0)
else:
	while True:
		now_candy = now_candy + 1
		total_candy += now_candy
		now_moves += 1
		if total_candy - (no_of_moves - now_moves) == no_of_candy:
			break
	print(no_of_moves - now_moves)


from collections import deque, Counter
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
(n, k) = read_int_array()
b = -2 * n - 3
c = n + n ** 2 - 2 * k
d = b ** 2 - 4 * c
sqrt_d = sqrt(d)
m1 = (-b + sqrt_d) / 2
m2 = (-b - sqrt_d) / 2
ans = m1 if 0 <= m1 <= n else m2
assert 0 <= ans <= n
print(int(ans))


(n, k) = map(int, input().split())
noe = 0
for i in range(1, n + 1):
	s = i * (i + 1) // 2
	if s == k:
		if i == n:
			noe = 0
			break
	elif s > k:
		if s - k + i == n:
			noe = s - k
			break
print(noe)


(n, k) = list(map(int, input().split()))
cnt = n * (n + 1) // 2 - k
uk1 = 0
uk2 = n + 1
while uk2 - uk1 > 1:
	mid = (uk2 + uk1) // 2
	if mid * (mid + 1) // 2 - (n - mid) >= k:
		uk2 = mid
	else:
		uk1 = mid
print(n - uk2)


(n, k) = map(int, input().split())
sum = 0
a = 0
for i in range(1, 1000000001):
	flag = 0
	sum += i
	a += 1
	if a == n:
		print(0)
		break
	if sum > k:
		if sum - (n - a) == k:
			print(n - a)
			break


datos = list(map(int, input().split()))
suma = 0
contadorr = 0
restantes = 0
con2 = 0
con3 = 0
for i in range(datos[0]):
	suma = suma + con2
	con2 += 1
	restantes = datos[0] - con2
	if datos[1] == 0:
		if suma >= restantes:
			contadorr += 1
	elif suma > datos[1]:
		if restantes + 1 == suma - datos[1]:
			contadorr = restantes + 1
			break
print(contadorr)


(n, k) = map(int, input().split(' '))
start = 0
end = n - 1
f = 0
while start <= end:
	j = (start + end) // 2
	if (n - j) * (1 + n - j) // 2 - j == k:
		print(j)
		f = 1
		break
	elif (n - j) * (1 + n - j) // 2 - j - k > 0:
		start = j + 1
	else:
		end = j - 1
if f == 0:
	print(start)


(n, k) = map(int, input().split())
c = 1
x = 1
inc = 1
y = 0
if c != k or x != n:
	while c <= k:
		inc += 1
		c = c + inc
		x += 1
	while c - (n - x) != k:
		inc += 1
		c = c + inc
		x += 1
	y = n - x
print(y)


def sm(x):
	return x * (x + 1) // 2
(n, k) = map(int, input().split())
ct = 0
while True:
	moves = n
	candies = k
	candies -= sm(ct)
	moves -= ct
	if moves == -candies:
		print(moves)
		break
	ct += 1


(n, k) = map(int, input().split())
if n == 1:
	print(0)
else:
	for i in range(1, n + 1):
		val = i * (i + 1) // 2
		if val - k == n - i:
			ite = i
			break
	print(n - i)


(n, k) = [int(x) for x in input().split()]
C = 2 * (n + k)
d = int(pow(9 + 4 * C, 0.5))
x = (-3 + d) // 2
print(n - x)


(n, k) = map(int, input().split())
mid = n // 2
(low, high) = (1, n)
while low <= high:
	mid = (low + high) // 2
	val = mid * (mid + 1) // 2 - (n - mid)
	if val == k:
		candies = n - mid
		break
	if val > k:
		high = mid
	else:
		low = mid
print(candies)


(n, k) = list(map(int, input().split()))
l = n
low = 1
high = n
mid = (high + low) // 2
while high <= l and low >= 1:
	a = mid * (mid + 1) / 2
	if a - (l - mid) == k:
		print(l - mid)
		break
	elif a - (l - mid) < k:
		low = mid
		mid = (high + low) // 2
	elif a - (l - mid) > k:
		high = mid
		mid = (high + low) // 2


counter1 = 0
string1 = list(input())
placeholdern = ''
placeholderb = ''
for p in string1:
	if p != ' ' and counter1 == 0:
		placeholdern = placeholdern + p
	elif p != ' ' and counter1 == 1:
		placeholderb = placeholderb + p
	elif p == ' ':
		counter1 = counter1 + 1
n = int(placeholdern)
k = int(placeholderb)
req = n - (-3 + (9 + 8 * n + 8 * k) ** (1 / 2)) / 2
print(int(req))


def gg(a):
	return a * 2 - n + (a - 1) * a / 2
(n, k) = map(int, input().split())
l = -1
r = n
while l + 1 < r:
	m = (l + r) // 2
	if gg(m) >= k:
		r = m
	else:
		l = m
print(n - r)


(a, b) = map(int, input().split())
if b == 0:
	sumi = 0
	for n in range(1, a + 1):
		sumi += n
		if sumi == a - n:
			print(a - n)
			break
else:
	sumi = 0
	for n in range(1, a + 1):
		sumi += n
		if sumi - (a - n) == b:
			print(a - n)
			break


import math
(n, k) = map(int, input().split())
r = (math.sqrt(9 + 8 * (k + n)) - 3) / 2
t = n - r
print(int(t))


import math
(n, k) = map(int, input().strip().split())
a = 2 * n + 3
b = math.sqrt(9 + 8 * n + 8 * k)
c = a - b
print(int(c // 2))


x = list(map(int, input().rstrip().split()))
for i in range(1000000000):
	if i * (i + 1) / 2 - (x[0] - i) == x[1]:
		print(x[0] - i)
		break


(n, k) = map(int, input().split(' '))
low = 0
high = n + 2
ans = -1
while low <= high:
	mid = (low + high) // 2
	add = mid * (mid + 1) // 2
	if add - (n - mid) == k:
		ans = n - mid
		break
	elif add - (n - mid) < k:
		low = mid + 1
	else:
		high = mid - 1
print(ans)


def bs(l, h, k, n):
	m = (l + h) // 2
	v = m * (m + 1) // 2 - (n - m)
	if v == k:
		return n - m
	elif v > k:
		return bs(l, m - 1, k, n)
	else:
		return bs(m + 1, h, k, n)

def solve(n, k):
	print(bs(1, n, k, n))
(n, k) = map(int, input().split())
solve(n, k)


(n, k) = map(int, input().split())
tot = 0
t = 0
add = 1
while tot - (n - t) != k and t < n:
	tot += t + 1
	t += 1
print(tot - k)


(n, k) = map(int, input().split())
sum = 0
i = 1
ans = 0
while i <= n:
	sum += i
	if sum >= k and sum - k == n - i:
		ans = n - i
		break
	i += 1
print(ans)


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

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

def number_of_candies(n: int, k: int) -> int:
	for i in range(1, n + 1):
		cur_sum = arith_sum(i)
		if cur_sum - can_eat(n, i) == k:
			return cur_sum - k

def can_eat(n, i):
	return n - i

def arith_sum(n: int) -> int:
	return (n + n * n) // 2
print(number_of_candies(n, k))


(n, k) = map(int, input().split())
for a in range(n + 1):
	b = n - a
	if a * (a + 1) / 2 - b == k:
		print(b)
		break


(n, k) = map(int, input().split())
for x in range(n + 1):
	y = x * x + 3 * x - 2 * n - 2 * k
	if y == 0:
		ans = n - x
		print(ans)
		break


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

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]
(n, k) = MI()
b = -(2 * n + 3)
c = n * n + n - 2 * k
x = (-b - (b * b - 4 * c) ** 0.5) // 2
y = (-b + (b * b - 4 * c) ** 0.5) // 2
(x, y) = (int(x), int(y))
for i in [x - 1, x, x + 1, y - 1, y, y + 1]:
	if i ** 2 + b * i + c == 0 and 0 <= i <= n - 1:
		print(i)
		break


(n, k) = map(int, input().split())
(a, b) = ((2 * n + 3 - (8 * (n + k) + 9) ** 0.5) // 2, (2 * n + 3 + (8 * (n + k) + 9) ** 0.5) // 2)
(c, d) = (n - a, n - b)
if c * (c + 1) // 2 - a == k:
	print(int(a))
else:
	print(int(b))


(n, k) = [int(i) for i in input().split()]
print((3 + 2 * n - int((8 * n + 8 * k + 9) ** 0.5)) // 2)


import bisect
(n, k) = input().split()
n = int(n)
k = int(k)
l = 0
r = n
while l < r:
	mid = l + (r - l) // 2
	x = mid * (mid + 1) // 2 - (n - mid)
	if x == k:
		print(n - mid)
		break
	elif x < k:
		l = mid + 1
	else:
		r = mid
if l == r:
	print(n - l)


import math
(n, k) = [int(x) for x in input().split(' ')]
ans = (2 * n + 3 - int(math.sqrt(8 * n + 8 * k + 9))) // 2
print(ans)


import math as m
(n, d) = map(int, input().split())
print(int((2 * n + 3 - m.sqrt(9 + 8 * (n + d))) / 2))


import math
(n, k) = map(int, input().split())
temp = 0
for i in range(1, n + 1):
	temp += i
	ans = temp - k
	if ans >= 0 and ans == n - i:
		break
print(ans)


(a, b) = list(map(int, input().split()))
k = 0
sum1 = 0
count = 0
while True:
	k += 1
	sum1 += k
	count += 1
	if count + (sum1 - b) == a:
		break
print(sum1 - b)


(tot, choc) = [int(i) for i in input().split()]
bg = 1
end = tot
while True:
	mid = (bg + end) / 2
	add = mid * (mid + 1) / 2
	sub = tot - mid
	if add - sub == choc:
		print(int(sub))
		break
	if add - sub < choc:
		bg = mid + 1
	else:
		end = mid - 1


from collections import defaultdict
(n, k) = [int(i) for i in input().split()]
for add in range(n + 1):
	eat = n - add
	if add * (add + 1) == 2 * (k + eat):
		print(eat)
		break


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

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

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

def lmp():
	return list(mp())

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

def smp():
	return map(str, inp().split())

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

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

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(a, b) = mp()
c = 0
x = 0
while not (c >= b and c - b + x == a):
	x += 1
	c += x
print(a - x)


L = list(map(int, input().split()))
n = L[0]
k = L[1]
print(int(n - (-3 + (9 + 8 * (n + k)) ** (1 / 2)) / 2))


def check(n, mid):
	temp = mid * (mid + 1)
	temp = temp / 2
	temp = temp - (n - mid)
	return temp
(n, k) = map(int, input().split(' '))
l = 0
r = n - 1
ans = -1
if n == 1:
	print(0)
else:
	while l <= r:
		mid = (l + r) // 2
		x = check(n, mid)
		if x == k:
			ans = n - mid
			break
		elif x < k:
			l = mid + 1
		else:
			r = mid
	print(ans)


(n, k) = map(int, input().split())
num = 1
Sum = 1
while Sum - (n - num) != k:
	num += 1
	Sum += num
print(n - num)


import math
(n, k) = input().split()
(n, k) = [int(n), int(k)]
rem = math.sqrt(8 * (n + k) + 9)
val = 2 * n + 3 - rem
print(int(val // 2))


def search(n, k):
	l = 0
	h = n + 1
	while l <= h:
		mid = int((l + h) / 2)
		if n - mid == mid * (mid + 1) / 2 - k:
			return n - mid
		elif n - mid > mid * (mid + 1) / 2 - k:
			l = mid + 1
		else:
			h = mid - 1
	return 0
(n, k) = map(int, input().split())
c = search(n, k)
print(c)


(n, k) = map(int, input().split())
L = 0
R = n * (n + 1) * 10
while R - L > 1:
	m = (L + R) // 2
	if m * (m + 1) // 2 - n + m < k:
		L = m
	else:
		R = m
print(n - R)


import math
(n, k) = map(int, input().split())
d = math.floor(math.sqrt(k * 2))
s = d * (d + 1) // 2
while s - n + d != k:
	d += 1
	s += d
print(n - d)


l = input().split(' ')
n = int(l[0])
k = int(l[1])
for i in range(1, n + 1):
	if i * (i + 1) / 2 - (n - i) == k:
		print(n - i)
		break


dul = 0
(n, k) = map(int, input().split())
sum1 = 0
if k == 0:
	for i in range(n - 1, -1, -1):
		sum1 = sum1 + 1
		dul = dul + sum1
		if dul == i:
			print(i)
			break
if k != 0:
	for i in range(n - 1, -1, -1):
		sum1 = sum1 + 1
		dul = dul + sum1
		if dul - i == k:
			print(i)
			break


def main():
	(n, k) = map(int, input().split())
	x = -(int((9 + 8 * n + 8 * k) ** 0.5) - 2 * n - 3) >> 1
	print(x)
main()


(n, x) = map(int, input().split())
i = 1
a = [0]
for i in range(1, 100000):
	a += [i + a[i - 1]]
i = 1
while True:
	if n + x == a[i] + i:
		print(n - i)
		break
	i += 1


import math
inp = list(map(int, input().split()))
(n, k) = (inp[0], inp[1])
delta = int(math.sqrt(9 + 8 * n + 8 * k))
them = int((-3 + delta) // 2)
print(n - them)


import sys
import math
(n, k) = map(int, sys.stdin.readline().split())
d = 9 + 8 * (k + n)
y = (-3 + int(d ** 0.5)) // 2
print(n - y)


import math
(n, k) = list(map(int, input().split()))
delta = 1 + 4 * 2 * k
d = 9 + 8 * (n + k)
res = int((-3 + math.sqrt(d)) / 2)
print(n - res)


(n, k) = input().split()
n = int(n)
k = int(k)
i = 1
flag = 0
while flag == 0:
	put = i * (i + 1) / 2
	put = put - (n - i)
	if put == k:
		print(n - i)
		flag = 1
	i += 1


from bisect import *
if True:
	l = [i * (i + 1) // 2 for i in range(1, 1000000)]
	(n, k) = map(int, input().split())
	for i in range(1, len(l)):
		if l[i - 1] - (n - i) == k:
			print(n - i)
			break


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

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

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

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

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

def main():
	(n, k) = vars()
	l = 1
	r = n
	eaten = 0
	while l <= r:
		m = (l + r) // 2
		inBag = m * (m + 1) // 2
		eaten = n - m
		if inBag - eaten == k:
			break
		elif inBag - eaten < k:
			l = m + 1
		else:
			r = m - 1
	print(eaten)
t = 1
for _ in range(t):
	main()


(n, k) = map(int, input().split())
for i in range(10 ** 5):
	if i * (i + 1) // 2 - (n - i) == k:
		print(n - i)


a = input().split(' ')
n = int(a[0])
k = int(a[1])
sweets = 0
add = 1
moves = 0
eat = 0
while moves < n:
	if sweets <= k or sweets == 0:
		sweets += add
		add += 1
		moves += 1
	elif sweets > k:
		moves += sweets - k
		eat += sweets - k
		sweets = sweets - (sweets - k)
print(eat)


import sys
import math
(n, k) = map(int, sys.stdin.readline().split())
i = 1
m = 0
while 1:
	m += i
	if m - n + i == k:
		print(n - i)
		exit()
	i += 1


from sys import stdin, stdout, exit
import math
(n, k) = list(map(int, stdin.readline().split()))
ans = round((-3 + math.sqrt(9 + 8 * (k + n))) / 2)
stdout.write(str(n - ans) + '\n')


(n, k) = [int(i) for i in input().split()]
i = 0
f = False
for i in range(n, -1, -1):
	n1 = (1 + n - i) / 2 * (n - i)
	if n1 - i == k:
		break
print(i)


(a, b) = map(int, input().split())
l = 0
r = a
ela = 0
m = 0
while l + 1 < r:
	m = (l + r) // 2
	ela = a - m
	pol = (m + 1) * m // 2
	if pol - m > b:
		r = m
	elif pol - m == b:
		break
		ans = ela
	else:
		l = m
fl = 0
(v, v2) = (m, m)
ans = ela
while not fl:
	if v * (v + 1) // 2 - (a - v) == b:
		fl = 1
		ans = a - v
		break
	if v2 * (v2 + 1) // 2 - (a - v2) == b:
		fl = 1
		ans = a - v2
		break
	if v - 1 >= 0:
		v -= 1
	if v2 + 1 <= a:
		v2 += 1
print(ans)


(n, e) = map(int, input().split(' '))
x = (9 + 8 * (n + e)) ** (1 / 2) - 3
x = x / 2
print(int(n - x))


(n, k) = map(int, input().strip().split())
c = 2 * (n + k)
ans = ((9 + 4 * c) ** 0.5 - 3) / 2
print(int(n - ans))


import math

def sportMafia(n, k):
	r = round(n + 1.5 - math.sqrt(2 * (n + k) + 2.75))
	return r
(n, k) = map(int, input().split())
print(sportMafia(n, k))


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

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

def good_enough(n, k, m):
	cur_sum = arith_sum(m)
	return cur_sum - can_eat(n, m) >= k

def number_of_candies(n: int, k: int) -> int:
	bad = 0
	good = n + 1
	while good - bad > 1:
		m = (good + bad) // 2
		if good_enough(n, k, m):
			good = m
		else:
			bad = m
	return arith_sum(good) - k

def can_eat(n, i):
	return n - i

def arith_sum(n: int) -> int:
	return (n + n * n) // 2
print(number_of_candies(n, k))


ln = [int(i) for i in input().split(' ')]
n = ln[0]
k = ln[1]
s = 0
i = 0
ans = -1
while s < 10 ** 10:
	i += 1
	s += i
	if (i + s) / 2 == (n + k) / 2:
		ans = s - k
		break
print(ans)


s = input()
(n, k) = s.split(' ')
(n, k) = (int(n), int(k))
cnt = 0
add = 0
u = 1
left = n
ans = 0
incase = 0
while add < k:
	add += u
	incase += u
	u += 1
	left = left - 1
useless = add - k
while useless != 0:
	ans += 1
	left = left - 1
	useless = useless - 1
e = 0
var = u
while e + var < left:
	e += var
	var += 1
ans = ans + e
print(ans)


(n, k) = input().split()
n = int(n)
k = int(k)
s = 0
l = 1
while (4 + s) / 2 * l != k + n and l != n + 1:
	s += 1
	l += 1
print(n - l)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def getReamin(action, n):
	n -= action
	ans = n * (n + 1) // 2 - action
	return ans

def main():
	(n, k) = invr()
	l = 1
	r = n
	res = 0
	while l <= r:
		mid = l + (r - l) // 2
		remain = getReamin(mid, n)
		if remain == k:
			res = mid
			break
		if remain > k:
			l = mid + 1
		else:
			r = mid - 1
	print(res)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
(n, k) = input().split()
n = int(n)
k = int(k)
candisInBox = 0
multi = 0
movement = 0
theDiffrance = 0
reminingCandies = 0
while movement <= n:
	multi = multi + 1
	movement = movement + 1
	candisInBox = candisInBox + multi
	theDiffrance = n - movement
	reminingCandies = candisInBox - k
	if candisInBox >= k:
		if theDiffrance == reminingCandies:
			print(theDiffrance)
			sys.exit()


def AP_Term(n):
	return n * (1 + n) // 2
(act, cleft) = map(int, input().split())
if cleft != AP_Term(act):
	low = 1
	high = act
	ans = 0
	while low <= high:
		mid = low + (high - low) // 2
		candy_in = AP_Term(mid)
		moves_left = act - mid
		if cleft == candy_in - moves_left:
			ans = moves_left
			break
		elif cleft > candy_in - moves_left:
			low = mid + 1
		else:
			high = mid - 1
	print(ans)
else:
	print(0)


(n, k) = map(int, input().split())
l = 0
r = n
while r - l > 1:
	m = (r + l) // 2
	su = 0
	s = k + m
	su = (1 - m + n) * (n - m) * 0.5
	if su >= s:
		l = m
	else:
		r = m
print(l)


import math
[n, k] = [int(i) for i in input().split()]
if n == 1:
	print(0)
else:
	r = int(math.sqrt(9 + 8 * (k + n)))
	y = (-3 + r) // 2
	print(n - y)


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


import random
a = input()
a = a.split()
actions = int(a[0])
candies = int(a[1])
search = 0
i = int(actions / 2)
time = 100
movement = int(actions / 4)
while search == 0:
	if time <= 0:
		for x in range(i - 5, i + 7):
			m = (actions - x) * (actions - x + 1) / 2 - x
			if candies == m:
				print(x)
				search = 1
		else:
			search = 1
	else:
		m = (actions - i) * (actions - i + 1) / 2 - i
		if candies == m:
			print(i)
			search = 1
		elif candies > m:
			i -= movement
		else:
			i += movement
	time -= 1
	movement = int(movement / 2)
	if movement < 1:
		time = 0


(n, k) = map(int, input().split())
i = 0
j = n
while i <= j:
	m = i + (j - i) // 2
	target = (n - m) * (n - m + 1) // 2
	if target - m == k:
		print(m)
		break
	elif target - m < k:
		j = m - 1
	else:
		i = m + 1


(n, k) = map(int, input().split())
sum = 0
x = 1
while sum < k or sum + x - k < n:
	sum += x
	x += 1
	n -= 1
print(n)


(n, k) = list(map(int, input().split()))
x = 0
su = 2 * (n + k)
while x * (x + 3) != su:
	x += 1
print(n - x)


(n, k) = [int(x) for x in input().split()]
Nbr_of_eaten_candies = 0
x = 1
step = 1
while step < n:
	if x + step + 1 - (n - step - 1) == k:
		Nbr_of_eaten_candies = n - step - 1
		break
	x = x + step + 1
	step = step + 1
print(Nbr_of_eaten_candies)


(n, k) = map(int, input().split())
c = 0
s = 0
cur = 0
while n > 0:
	if s > k:
		minus = s - k
		n -= minus
		c += minus
		s = k
	else:
		cur += 1
		s += cur
		n -= 1
print(c)


from math import sqrt, floor
inputs = input().split(' ')
n = int(inputs[0])
k = int(inputs[1])
m1 = (-3 + sqrt(9 + 8 * (n + k))) / 2
print(n - floor(m1))


import math
(n, k) = map(int, input().split())
a = 1
b = -1
c = -2 * (n + k)
d = b ** 2 - 4 * a * c
sol1 = (-b - math.sqrt(d)) / (2 * a)
sol2 = (-b + math.sqrt(d)) / (2 * a)
if sol1 > sol2:
	print(abs(int(sol1) - n - 1))
else:
	print(abs(int(sol2) - n - 1))


(actions, end_total_candies) = [int(i) for i in input().split()]
candies = 1
if actions == 1:
	print(0)
else:
	for i in range(1, actions):
		candies = candies + i + 1
		if candies >= end_total_candies + (actions - i - 2):
			print(candies - end_total_candies)
			exit()


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


import math
(m, k) = map(int, input().split())
print(m - int((math.sqrt(8 * (k + m) + 9) - 3) // 2))


DEBUG = False

def debug(to_print_args):
	if not DEBUG:
		return
	for arg in to_print_args:
		print(arg, end=' ')
	print()
inp = input().split()
n = int(inp[0])
k = int(inp[1])
if n == 1 and k == 1:
	print(0)
	exit()
step_counter = n
sum = 0
result = int()
for i in range(1, n):
	if sum - step_counter == k:
		result = step_counter
		break
	else:
		sum += i
		step_counter -= 1
		i += 1
		debug([step_counter])
debug([step_counter, n, k, sum])
print(step_counter)


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


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

def k(n, t):
	return t - n

def bin(l, r, res):
	t = r
	while l + 1 < r:
		mid = (l + r) // 2
		if f(mid) - k(mid, t) < res:
			l = mid
		else:
			r = mid
	return t - r
(t, res) = map(int, input().split())
print(bin(1, t, res))


import math
(n, k) = map(int, input().split())
e = math.sqrt(8 * n + 8 * k + 9)
a = (3 + 2 * n - e) // 2
print(int(a))


import sys
from fractions import gcd
from math import ceil, sqrt, sin, pi, tan
from collections import defaultdict
read = sys.stdin.buffer.readline
import heapq
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
as0 = ord('0')
as1 = ord('1')
for _ in range(1):
	(n, k) = mi()
	(l, h) = (0, n)
	while l <= h:
		x = (l + h) // 2
		n1 = n - x
		if n1 >= 0:
			sm = n1 * (n1 + 1) // 2
		else:
			sm = -10000000000
		if sm > x + k:
			l = x + 1
		elif sm < x + k:
			h = x - 1
		else:
			print(x)
			break


(n, k) = map(int, input().split())
m = n // 2
mini = 0
maxi = n - 1
while maxi > mini:
	tot = (n - m) * (n - m + 1) // 2 - m
	if tot > k:
		mini = m + 1
		m = (mini + maxi) // 2
	elif tot < k:
		maxi = m - 1
		m = (mini + maxi) // 2
	elif tot == k:
		break
print(m)


import math
line = input().split()
N = int(line[0])
K = int(line[1])
n = (-3 + math.sqrt(9 + 4 * (2 * N + 2 * K))) / 2
print(int(N - n))


import math
(n, k) = list(map(int, input().split(' ')))
b = 3
a = 1
c = -2 * (n + k)
D = int(math.sqrt(math.pow(b, 2) - 4 * a * c))
ans = int((-b + D) / 2 * a)
print(n - ans)


(n, k) = map(int, input().split())
r = min(n, int(1000000.0))
for i in range(1, r + 1):
	sm = i * (i + 1) // 2
	y = sm - k
	if y >= 0 and y + i == n:
		print(y)
		break


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = 1

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	a = 1
	b = 2 * n + 3
	c = n + n ** 2 - 2 * k
	x1 = b + int(mt.sqrt(b ** 2 - 4 * a * c))
	x2 = b - int(mt.sqrt(b ** 2 - 4 * a * c))
	if x1 % 2 == 0 and x1 // 2 <= n:
		return x1 // 2
	return x2 // 2
for _ in range(t):
	(n, k) = map(int, input().split())
	print(solve())


l1 = [int(x) for x in input().split()]
moves = l1[0]
final = l1[1]
i = 0
total = 0
while moves:
	i += 1
	total += i
	moves -= 1
	if total >= final:
		if total - final == moves:
			print(total - final)
			break


(n, k) = map(int, input().split())
for p in range(1, n + 1):
	s = p * (p + 1) // 2
	if s - (n - p) == k:
		print(n - p)
		break


import math
(n, k) = map(int, input().split())
a1 = (-3 + math.sqrt(9 + 8 * (n + k))) / 2
a2 = (-3 - math.sqrt(9 + 8 * (n + k))) / 2
print(n - int(max(a1, a2)))


(n, k) = map(int, input().split())
lo = 0
if n == 1:
	print(0)
	exit()
hi = 10 ** 20
ans = 0

def check(mid):
	moves = mid
	eat = n - mid
	if moves * (moves + 1) // 2 - eat < k:
		return 0
	elif moves * (moves + 1) // 2 - eat >= k:
		return 1
while lo <= hi:
	mi = lo + hi >> 1
	if check(mi):
		ans = mi
		hi = mi - 1
	else:
		lo = mi + 1
print(n - ans)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, k) = invr()
ans = 0
lo = 0
hi = n

def possible(a, b):
	koyta = a * (a + 1) // 2
	return koyta >= b + k
while hi >= lo:
	mid = (hi + lo) // 2
	if possible(n - mid, mid):
		lo = mid + 1
		ans = mid
	else:
		hi = mid - 1
print(ans)


(n, p) = input().split()
(n, p) = (int(n), int(p))
for i in range(0, n + 1):
	if i ** 2 + 3 * i - 2 * (n + p) == 0:
		print(n - i)
		break


(n, k) = map(int, input().split())
l = 0
u = n
c = (l + u) // 2
while (n - c) * (n - c + 1) // 2 - c != k:
	if (n - c) * (n - c + 1) // 2 - c > k:
		l = c
	else:
		u = c
	c = (l + u) // 2
print(c)


(n, k) = map(int, input().split())
D = (8 * (n + k) + 9) ** 0.5
b = 2 * n + 3
t1 = (b + D) // 2
t2 = (b - D) // 2
if t1 <= n:
	ans = t1
else:
	ans = t2
print(int(ans))


(n, k) = map(int, input().split())
t = (n + k) * 2 + 9 / 4.0
print(int(n - t ** 0.5 + 1.5))


from math import sqrt
(n, k) = map(int, input().split())
(a, b, c) = (1, 2 * n + 3, n * n + n - 2 * k)
r = b ** 2 - 4 * a * c
(x1, x2) = (-1, -1)
if r > 0:
	num_roots = 2
	x1 = (b + sqrt(r)) / (2 * a)
	x2 = (b - sqrt(r)) / (2 * a)
elif r == 0:
	num_roots = 1
	x1 = -b / 2 * a
(x1, x2) = (int(x1), int(x2))
if x2 == -1:
	print(x1)
else:
	print(min(x1, x2))


(n, k) = map(int, input().split())
ng = -1
ok = n + 1
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	if mid * (mid + 1) // 2 - (n - mid) >= k:
		ok = mid
	else:
		ng = mid
ans = n - ok
print(ans)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
sm = 1
mv = 1
while sm != k + n - mv:
	mv += 1
	sm += mv
print(max(0, sm - k))


(n, k) = map(int, input().split())
candy = 0
eaten = 0
i = 1
adder = 1
while i <= n:
	if candy <= k:
		candy += adder
		i += 1
		adder += 1
	elif candy > k:
		eaten += candy - k
		i += candy - k
		candy = k
print(eaten)


(n, k) = map(int, input().split())
a = 1
b = -(2 * n + 3)
c = n * n + n - 2 * k
d = int((b * b - 4 * a * c) ** 0.5)
s1 = (-b + d) // (2 * a)
s2 = (-b - d) // (2 * a)
if s1 >= 0 and s1 <= n:
	print(s1)
else:
	print(s2)


import sys
import math
(n, k) = map(int, sys.stdin.readline().split())
a = (math.sqrt(9 + 8 * (n + k)) - 3) / 2
print(int(n - a))


import math
numbers = list(map(int, input().split()))
x = numbers[0]
y = numbers[1]
a = (-3 + math.sqrt(9 + 8 * (x + y))) / 2
b = x - a
print(int(b))


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	print(n - int(((9 + 8 * (n + k)) ** 0.5 - 3) / 2))
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()


(n, k) = map(int, input().split())
(i, x) = (0, 0)
while True:
	(i, n) = (i + 1, n - 1)
	x += i
	if x - n == k:
		print(n)
		exit()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible(x):
	days = n - x
	tot = days * (days + 1) // 2
	return tot - x <= k
(n, k) = value()
low = 0
high = n
while low <= high:
	mid = (low + high) // 2
	if possible(mid):
		high = mid - 1
	else:
		low = mid + 1
print(low)


(n, k) = map(int, input().split())
b = -(2 * n + 3)
c = n ** 2 + n - 2 * k
ans1 = (-b + (b * b - 4 * c) ** 0.5) // 2
ans2 = (-b - (b * b - 4 * c) ** 0.5) // 2
if ans1 >= 0 and ans1 < n:
	print(int(ans1))
else:
	print(int(ans2))


n = input()
a = [int(i) for i in n.split()]
a = tuple(a)
sm = 0
ans = a[0]
i = 0
while sm - ans != a[1]:
	ans -= 1
	i += 1
	sm += i
print(ans)


(n, k) = list(map(int, input().split()))
a = pow(9 + 8 * (n + k), 0.5) - 3
a //= 2
print(int(n - a))


def check(x, n, k):
	ate = x
	rem = n - ate
	if rem * (rem + 1) // 2 == k + ate and rem >= 0 and (ate >= 0):
		return True
	return False

def main():
	(n, k) = map(int, input().split())
	b = -1 * (2 * n + 3)
	a = 1
	c = n ** 2
	c += n - 2 * k
	d = (b ** 2 - 4 * a * c) ** 0.5
	x1 = (-b + d) / 2 * a
	x2 = (-b - d) / 2 * a
	if check(x1, n, k):
		print(int(x1))
		return
	print(int(x2))
main()


(n, k) = map(int, input().split())
a = 1
b = 2 * n + 3
c = n ** 2 + n - 2 * k
d = (b ** 2 - 4 * a * c) ** 0.5
x1 = (-b + d) // 2 * a
x2 = (-b - d) // 2 * a
print(int(abs(max(x1, x2))))


(n, k) = map(int, input().split())
box = 0
ate = 0
put = 1
while n != 0:
	if box < k:
		box = box + put
		put = put + 1
	else:
		ate = ate + 1
		box = box - 1
	n = n - 1
print(ate)


from math import sqrt
inp = input().split(' ')
n = int(inp[0])
k = int(inp[1])
a = 3 + 2 * n
b = 8 * n + 8 * k + 9
print(int((a - sqrt(b)) / 2))


from sys import stdin, stdout
(N, K) = [int(x) for x in stdin.readline().split()]
s = 0
for i in range(1, N + 1):
	s += i
	minus = N - i
	num = s - minus
	if num == K:
		print(minus)
		break


(n, k) = map(int, input().split())
i = 0
j = n
while j:
	i += 1
	j -= 1
	m = i * (i + 1) // 2
	if m - j == k:
		break
print(j)


import sys, collections
(n, k) = map(int, sys.stdin.readline().split())
left = 0
right = n + 1
while left < right:
	mid = (left + right) // 2
	candy = n - mid
	total = candy * (candy + 1) // 2 - mid
	if total < k:
		right = mid
	elif total > k:
		left = mid + 1
	else:
		print(mid)
		break


(n, k) = list(map(int, input().split()))
for i in range(n + 1):
	g = i * (i + 1) / 2
	c = n - i
	if g - c == k:
		print(c)
		break


import sys
from collections import deque
IS_LOCAL = False

def read_one(dtype=int):
	return dtype(input())

def read_multiple(f, dtype=int):
	return f(map(dtype, input().split()))

def swap(x, y):
	return (y, x)

def main():
	(n, k) = (9, 11)
	if not IS_LOCAL:
		(n, k) = read_multiple(tuple)

	def ssum(x):
		return (x + 1) * x // 2
	(l, r) = (0, n)
	while l < r:
		e = (l + r) // 2
		x = ssum(n - e) - (k + e)
		if x > 0:
			l = e + 1
		else:
			r = e
	print(l)
if len(sys.argv) > 1 and sys.argv[1] == 'True':
	IS_LOCAL = True
main()


(n, k) = map(int, input().split())
inside = (9 + 8 * (n + k)) ** 0.5
inside = int(inside)
m = (-3 + inside) // 2
a = n - m
print(a)


ints = [int(x) for x in input().split()]
n = ints[0]
k = ints[1]
print(int(n - ((8 * (n + k) + 9) ** (1 / 2) - 3) / 2))


def su(a):
	s = 0
	if a % 2 == 1:
		s += a
		a -= 1
	return s + (a + 1) * (a // 2)
(n, k) = map(int, input().split())
hi = n
lo = 0
a1 = (hi + lo) // 2
c = su(a1)
while hi > lo:
	if c - (n - a1) < k:
		lo = a1 + 1
	elif c - (n - a1) > k:
		hi = a1 - 1
	else:
		break
	a1 = (hi + lo) // 2
	c = su(a1)
print(n - a1)


inp = list(map(int, input().strip().split()))
moves = inp[0]
candiesAtTheEnd = inp[1]

def find(moves, candiesAtTheEnd):
	result = -1
	start = 0
	end = moves - 1
	while result != candiesAtTheEnd:
		mid = (end - start + 1) // 2 + start
		pluses = moves - mid
		minuses = mid
		result = (pluses + 1) / 2 * pluses
		result = result - minuses
		if result == candiesAtTheEnd:
			return minuses
		elif result > candiesAtTheEnd:
			start = mid
		else:
			end = mid
result_final = find(moves, candiesAtTheEnd)
print(result_final)


(x, y) = map(int, input().split())
b = 0
for a in range(1, x + 1):
	c = x - a
	b += a
	if b - c == y:
		print(c)
		break


fstLine = list(map(int, input().split(' ')))
(turnsLeft, candies, turn) = (fstLine[0], 0, 1)
while turnsLeft != 0 and candies - turnsLeft != fstLine[1]:
	candies += turn
	turn += 1
	turnsLeft -= 1
print(turnsLeft)


import math
(n, k) = [int(s) for s in input().split()]
m = math.ceil((-1 + math.sqrt(1 + 8 * k)) / 2)
eat = n - m
s = (m ** 2 + m) // 2
while s - eat != k:
	m += 1
	eat = n - m
	s = (m ** 2 + m) // 2
print(s - k)


def check(mid):
	added = n - mid
	total = added * (added + 1) // 2
	return total - mid >= k
(n, k) = map(int, input().split())
low = 0
high = n - 1
while low < high:
	mid = (low + high + 1) // 2
	if check(mid):
		low = mid
	else:
		high = mid - 1
print(low)


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd

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, k) = get_ints()
if k == 0:
	d = 1 + 8 * n
	ans = floor((-1 + sqrt(d)) / 2)
	x = ans * (ans + 1) // 2
	print(x)
	exit()
d = 1 + 8 * k
ans = ceil((-1 + sqrt(d)) / 2)
chance_left = n - ans
while ans * (ans + 1) // 2 - chance_left < k:
	chance_left -= 1
	ans += 1
print(chance_left)


n = list(map(int, input().split()))
count_turn = n[0]
count_K = n[1]
count_K_b = 0
ate = 0
count_t = 0
counter = 1
while count_turn != count_t:
	k = False
	if count_t == 0:
		count_K_b += counter
		counter += 1
	elif count_K_b > count_K:
		r = count_K_b - count_K
		count_K_b -= r
		ate += r
		k = True
		count_t += r
	else:
		count_K_b += counter
		counter += 1
	if not k:
		count_t += 1
print(ate)


def s(n, adds_count):
	s = int((1 + adds_count) / 2 * adds_count) - n + adds_count
	return s
(n, k) = map(int, input().split())
n_add = (n + 1) // 2
diff = (n + 1) // 2
res = s(n, n_add)
while res != k:
	diff = (diff + 1) // 2
	if res > k:
		n_add -= diff
	else:
		n_add += diff
	res = s(n, n_add)
print(n - n_add)


(n, k) = map(int, input().split())
d = 9 + 8 * k + 8 * n
print(n - (-3 + int(d ** 0.5 + 1e-06)) // 2)


from collections import defaultdict
from functools import reduce
import atexit, io, sys
from bisect import bisect_left

def find_ge(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i

def main():
	p = [0] * 10 ** 5
	p[0] = 1
	for _ in range(1, 100000):
		p[_] = p[_ - 1] + _ + 1
	(n, k) = list(map(int, input().split()))
	r = find_ge(p, k)
	for i in range(r, 100000):
		if i + 1 + (p[i] - k) == n:
			print(p[i] - k)
			break
main()


(n, k) = map(int, input().strip().split())
the_sum = n + k
the_sum *= 2
eps = 0.0001
l = 0
r = the_sum
while l < r:
	mid = (l + r) // 2
	result = mid ** 2 + 3 * mid
	if result == the_sum:
		l = mid
		break
	elif result > the_sum:
		r = mid
	else:
		l = mid + 1
print(n - l)


(k, n) = map(int, input().split())
put = 1
while put * (put + 1) // 2 <= n + (k - put):
	if put * (put + 1) // 2 - (k - put) == n:
		print(k - put)
		break
	put += 1


(n, k) = input().split()
n = int(n)
k = int(k)
i = 1
f = n
while i <= f:
	med = (i + f) // 2
	res = med * (med + 1) / 2 - (n - med)
	if res == k:
		print(n - med)
		break
	elif res > k:
		f = med - 1
	else:
		i = med + 1


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math

def validation(n, k, x):
	if x * (x + 1) // 2 - (n - x) == k:
		return 0
	if x * (x + 1) // 2 - (n - x) > k:
		return 1
	return 2
(n, k) = getList()
l = 0
r = 1000000001
while True:
	mid = (l + r) // 2
	flag = validation(n, k, mid)
	if flag == 0:
		ans = mid
		break
	elif flag == 1:
		r = mid
	else:
		l = mid
print(n - ans)


import math
(n, k) = [int(i) for i in input().split()]
x = 2 * k + 2 * n
r = -1.5 + math.sqrt(9 + 4 * x) * 0.5
print(int(n - r))


DEBUG = False

def debug(to_print_args):
	if not DEBUG:
		return
	for arg in to_print_args:
		print(arg, end=' ')
	print()

def solve(n, k):
	sum = 0
	for i in range(1, n):
		sum += i
		debug([sum, i])
		if sum - (n - i) == k:
			return n - i
	return 0
inp = input().split()
n = int(inp[0])
k = int(inp[1])
print(solve(n, k))


(n, k) = list(map(int, input().split()))
banka = 0
nakop = 0
eat = 0
while banka != k + n - nakop:
	nakop += 1
	banka += nakop
print(n - nakop)


from math import sqrt
s = input().split(' ')
(n, k) = (int(s[0]), int(s[1]))
C = n * n + n - 2 * k

def solve(a, b, c):
	delta = b * b - 4 * a * c
	delta = int(sqrt(delta))
	return (-b - delta) // (2 * a)
print(solve(1, -(2 * n + 3), C))


import math
(n, k) = map(int, input().split())
a = 1
b = 3
c = -2 * n - 2 * k
ans1 = (-b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
ans2 = (-b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
if ans1 >= 0:
	print(int(n - ans1))
else:
	print(int(n - ans2))


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


from collections import Counter

def solve():
	(n, k) = tuple(map(lambda x: int(x), input().split()))
	(low, high) = (0, n)
	while low <= high:
		eaten = (low + high) // 2
		added = (n - eaten) * (n - eaten + 1) / 2
		if added - eaten >= k:
			low = eaten + 1
		else:
			high = eaten - 1
	print(high)
solve()


from collections import defaultdict as dd, deque as dq
import math, string
import sys

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	x = (-3 + math.sqrt(9 + 8 * (N + K))) // 2
	return int(x * (x + 1) // 2 - K)
print(solve())


def isqrt(n):
	x = n
	y = (x + 1) // 2
	while y < x:
		x = y
		y = (x + n // x) // 2
	return x
(n, k) = list(map(int, input().split(' ')))
answer = int(-1 / 2 * isqrt(8 * k + 8 * n + 9) + n + 3 / 2)
print(answer)


import math
(a, b) = map(int, input().split())
c = -3 + math.sqrt(9 + 4 * (2 * a + 2 * b))
c = c / 2
ans = a - c
print(int(ans))


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


(n, k) = [int(i) for i in input().split()]
res = 0
for i in range(1, n + 1):
	res += i
	if res - (n - i) == k:
		print(n - i)
		break


(n, k) = map(int, input().split())
(sum, i) = (0, 1)
m = 0
while sum - k != n - m:
	sum += i
	i += 1
	m += 1
print(sum - k)


import math
(n, k) = map(int, input().split())
a = 1
b = 3
c = 2 * n + 2 * k
c = c * -1
r1 = (-b + math.sqrt(b * b - 4 * a * c)) // 2 * a
r2 = (-b - math.sqrt(b * b - 4 * a * c)) // 2 * a
ans = max(r1, r2)
ans = n - ans
print(int(ans))


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


from math import sqrt
(n, k) = [int(ele) for ele in input().split(' ')]
P = (-3 + int(sqrt(8 * n + 8 * k + 1))) // 2
E = n - P - 1
print(E)


(n, k) = input().split()
n = int(n)
k = int(k)
l = 0
a = 0
p = 1
while n > 0:
	if a <= k:
		a = a + p
		p = p + 1
		n = n - 1
	if a > k:
		m = a - k
		a = a - m
		l = l + m
		n = n - m
print(l)


(turns, candies) = map(int, input().split())
summ = 0
turn = 0
while candies != summ - (turns - turn):
	turn += 1
	summ += turn
print(turns - turn)


aa = list(input().split())
n = int(aa[0])
k = int(aa[1])
x = (-1 * 3 + (9 + 8 * (n + k)) ** 0.5) / 2
x = int(x)
print(n - x)


import math
import sys
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 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()))
(n, k) = mi()
d = (2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)
print(int(2 * n + 3 - math.sqrt(d)) // 2)


import math
import heapq
from collections import deque
t = list(map(int, input().split()))
n = t[0]
k = t[1]

def binary_search(length, curr, val):
	right = length - 1
	left = 0
	while right >= left:
		mid = left + (right - left) // 2
		ans = mid * (mid + 1) // 2 - (length - mid)
		if ans == val:
			return length - mid
		if ans < val:
			left = mid + 1
		if ans > val:
			right = mid - 1
sumi = n * (n + 1) // 2
if sumi == k:
	print(0)
else:
	print(binary_search(n, sumi, k))


(n, k) = map(int, input().split())
summa = 0
ans = 0
i = 1
while i < n + 1:
	summa += i
	if summa > k:
		ans += summa - k
		n -= summa - k
		summa = k
	i += 1
print(ans)


(n, k) = map(int, input().split())
cnt = 0
c = 0
i = 0
while i != n:
	c = c + 1
	cnt = c + cnt
	if cnt - (n - c) == k:
		break
	i = i + 1
print(n - c)


import math
(n, k) = map(int, input().split())
p = int((-3 + int(math.sqrt(9 + 8 * (n + k)))) / 2)
print(int(p * (p + 1) / 2) - k)


(inp, out) = map(int, input().split())
count = 1
total_cand = 0
ate = inp + 1
for i in range(inp + 1):
	total_cand += i
	ate -= 1
	if total_cand - ate == out:
		print(ate)
		break


from math import sqrt
(n, k) = map(int, input().split())
x = n ** 2 + n - 2 * k
descrim = int(sqrt((2 * n + 3) ** 2 - 4 * x))
answer1 = (2 * n + 3 + descrim) // 2
answer2 = (2 * n + 3 - descrim) // 2
k1 = n - answer1
k2 = n - answer2
if k1 * (k1 + 1) // 2 == k - answer1:
	print(answer1)
else:
	print(answer2)


(n, k) = tuple(map(int, input().split()))
ileZja = n // 2
ileWlo = 0
a = 0
b = n
wynik = False
while not wynik:
	ileZja = (a + b) // 2
	ileWlo = (n - ileZja) * (n - ileZja + 1) // 2
	if ileWlo - ileZja == k:
		wynik = True
		break
	elif ileWlo - ileZja > k:
		a = ileZja
	else:
		b = ileZja
print(ileZja)


import sys

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

def dinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rt(x1, x2, y3):
	print(0.5 * (x2 + x1) * y3)

def main():
	(n, k) = rinput()
	i = 0
	t = 0
	while k > i:
		t += 1
		i += t
	c = n - t
	i -= c
	while i != k:
		t += 1
		i += t + 1
		c -= 1
	print(c)
main()


tope = 447210
arr = []
for i in range(1, tope):
	arr.append(i * (i + 1) // 2)
(n, k) = map(int, input().split())
i = 0
while i + 1 + arr[i] - k < n:
	i += 1
print(arr[i] - k)


(n, k) = input().split()
(n, k) = (int(n), int(k))
(s, i, nn) = (0, 0, n)
while nn >= 0:
	if s - nn == k:
		print(nn)
		break
	nn -= 1
	i += 1
	s = s + i


(a, b) = map(int, input().split())
print(int(a - ((9 + 8 * (a + b)) ** 0.5 - 3) / 2))


(n, k) = map(int, input().split())
t = 0
while True:
	if t * (t + 1) // 2 - (n - t) == k:
		print(n - t)
		exit(0)
	else:
		t += 1


(n, k) = map(int, input().split())
d21 = (2 * n + 3 - (8 * (n + k) + 9) ** 0.5) // 2
d11 = n - d21
d22 = (2 * n + 3 + (8 * (n + k) + 9) ** 0.5) // 2
d12 = n - d22
if d11 * (d11 + 1) // 2 - d21 == k:
	print(int(d21))
else:
	print(int(d22))


import sys
sys.setrecursionlimit(10 ** 6)
(n, k) = map(int, input().split())
print(n - int(-3 + (9 + 8 * k + 8 * n) ** 0.5) // 2)


(actions, remaining_candies) = map(int, input().split())
total = 0
acc = 1
if actions == remaining_candies == 1:
	actions = 0
elif remaining_candies:
	while total - actions != remaining_candies:
		total += acc
		acc += 1
		actions -= 1
else:
	while total < actions:
		total += acc
		acc += 1
		actions -= 1
	print(total)
	exit()
print(actions)


import sys
import math

def sum_of_sequence(x):
	return x * (x + 1) / 2
num = sys.stdin.readline().split(' ')
line_one = [int(x) for x in num]
actions = line_one[0]
candies = line_one[1]
res = (-3 + math.sqrt(9 + 8 * (candies + actions))) / 2
print(actions - int(res))


(t, k) = map(int, input().split())
c = -2 * (k + t)
r1 = (-3 + (9 - 4 * c) ** 0.5) // 2
r2 = (-3 - (9 - 4 * c) ** 0.5) // 2
n = max(r1, r2)
ans = n * (n + 1) // 2
print(int(ans - k))


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

def condn(i):
	if i * (i + 1) // 2 - (n - i) >= k:
		return True
	else:
		return False
l = 0
u = n
ans = -1
while l <= u:
	mid = (l + u) // 2
	if condn(mid):
		ans = mid
		u = mid - 1
	else:
		l = mid + 1
print(n - ans)


import math
(n, k) = list(map(int, input().split()))
x = 2 * (n + k)
root = (9 - 4 * -x) ** 0.5
c = (-3 + root) / 2
ans = n - c
print(int(ans))


(n, k) = map(int, input().split())
start = 0
cnt = n
cur = 1
while start <= k:
	start += cur
	cnt -= 1
	cur += 1
ans = 0
if start != k:
	while cnt > 0:
		if start == k:
			start += cur
			cur += 1
			cnt -= 1
		ans += start - k
		cnt -= start - k
		start = k
print(ans)


(n, k) = map(int, input().split())
Min = 1
Max = n
while Min <= Max:
	mid = (Min + Max) // 2
	A = mid * (mid + 1) / 2 - (n - mid)
	if k == A:
		print(n - mid)
		break
	elif A > k:
		Max = mid - 1
	else:
		Min = mid + 1


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

def search(s, e):
	h = s + e >> 1
	w = h * (h + 1) >> 1
	if w - k > n - h:
		return search(s, h - 1)
	if w - k < n - h:
		return search(h + 1, e)
	return n - h
print(search(1, n))


def main():
	(n, k) = map(int, input().split())
	candy_turn = 0
	candy_sum = 0
	turns_counter = 0
	while candy_sum < k + n - turns_counter:
		turns_counter += 1
		candy_turn += 1
		candy_sum += candy_turn
	print(n - turns_counter)
main()


(moves, left) = map(int, input().split())
s = 0
flag = 0
for i in range(1, moves + 1):
	s = s + i
	if s - moves + i == left:
		flag = 1
		break
if flag == 1:
	print(moves - i)
else:
	print(0)


import math
(N, K) = input().split()
N = int(N)
K = int(K)
print(N - int((-3 + math.sqrt(9 + 8 * (N + K))) // 2))


import sys
import math
import itertools
import functools
import collections
import operator

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 wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(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 divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, k) = mi()
t = math.ceil(math.sqrt(2 * (n + k) + 2.25) - 1.5)
print(n - t)


import math
(n, k) = map(int, input().split())
candies_ate = n + 1 - int((8 * n + 8 * k + 9) ** 0.5 / 2)
print(candies_ate)


from math import *
(n, k) = list(map(int, input().split()))
val = int(sqrt(9 + 8 * (n + k)))
ans = (-3 + val) // 2
print(n - ans)


import io, sys
input = lambda f=io.StringIO(sys.stdin.buffer.read().decode()).readline: f().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
(n, k) = mi()
ans = None
for x in range(1, n + 1):
	if x * (x + 3) == 2 * (k + n):
		ans = n - x
		break
print(ans)


import math

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

def calc_k(l, r):
	return calc_sum(l) - r
(n, k) = map(int, input().split())
i = math.ceil(n / 2)
l = i
r = n - l
while True:
	k_ = calc_k(l, r)
	if k_ > k:
		l = l - i
		r = n - l
	elif k_ < k:
		r = r - i
		l = n - r
	i = math.ceil(i / 2)
	if k_ == k:
		break
print(r)


(n, k) = map(int, input().split())
count = 0
for i in range(1, n + 1):
	count += i
	if count >= k and count - k == n - i:
		print(n - i)
		break


(n, k) = [int(i) for i in input().split()]
a = pow(1 + 2 * k + 2 * n, 0.5) - 1
print(n - int(a))


from __future__ import division
from math import sqrt, ceil, floor
(n, k) = map(int, input().split())
print(n - floor((sqrt(9 + 8 * (k + n)) - 3) / 2))


import math
(n, k) = [int(i) for i in input().split()]
q = 8 * k + 8 * n + 9
q = int(math.sqrt(q))
ans = (-3 + q) // 2
print(n - ans)


import math
(n, k) = input().split()
(n, k) = [int(n), int(k)]
number = math.ceil(n / 2)
b = 2 * n + 3
b2 = b ** 2
c = n ** 2 + n - 2 * k
root = (b2 - 4 * c) ** (1 / 2)
output = abs(b - root) / 2
print(int(output))


def candies(n, r):
	box = 0
	counter = 1
	while box < r:
		box += counter
		n -= 1
		counter += 1
	if n == box - r:
		return n
	elif n > box - r:
		left = n - (box - r)
		toeat = 0
		while toeat < left:
			toeat += counter
			counter += 1
			left -= 1
		return box - r + toeat
(n, r) = list(map(int, input().split()))
print(candies(n, r))


import sys
import math
from collections import defaultdict
from collections import Counter
(n, k) = map(int, input().split())
c = 0
while c <= n:
	c += 1
	t = c * (c + 1) // 2 - (n - c)
	if t == k:
		print(n - c)
		break


from sys import stdin
from math import sqrt

def main():
	(n, k) = map(int, input().split())
	m = int((-3 + sqrt(9 + 8 * (k + n))) / 2)
	print(n - m)
main()


import sys
import math
(n, k) = [int(i) for i in sys.stdin.readline().split()]
print(n - int((math.sqrt(9 + 8 * (n + k)) - 3) / 2))


from collections import Counter
import math
(n, k) = [int(x) for x in input().split()]
sum = 0
for i in range(n):
	sum = sum + i
	if sum - k == n - i:
		break
if sum == 0:
	sum = 1
print(sum - k)


(n, k) = map(int, input().split())
l = 0
h = n
while l < h:
	m = (l + h) // 2
	if (n - m) * (n - m + 1) // 2 - m > k:
		l = m + 1
	else:
		h = m
print(l)


def cal(x, n):
	return (1 + n - x) * (n - x) // 2 - x
(n, k) = map(int, input().strip().split())
(low, hgh, mid) = (0, n, -1)
while low <= hgh:
	mid = (low + hgh) // 2
	cm = cal(mid, n)
	if cm == k:
		print(mid)
		break
	elif cm > k:
		low = mid + 1
	else:
		hgh = mid - 1


(n, k) = map(int, input().split())
a = []
i = 0
while (3 * i + i ** 2) // 2 - n != k:
	i += 1
print(n - i)


try:
	while True:
		import math
		(n, k) = map(int, input().split())
		print(n - (int(math.sqrt(9 + 8 * (n + k))) - 3) // 2)
except:
	pass


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, k) = mapin()
d = ((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k)) ** 0.5
c1 = (2 * n + 3 + d) / 2
c2 = (2 * n + 3 - d) / 2
if c1 < n:
	print(int(c1))
else:
	print(int(c2))


import math
[n, k] = input().split(' ')
n = int(n)
k = int(k)
a = 1
b = -2 * n - 3
c = n * n + n - 2 * k
print(int((-b - math.sqrt(b * b - 4 * a * c)) / (2 * a)))


def candy_eaten(n, k):
	choco = 1
	last = 1
	eat = 0
	i = n - 1
	while i > 0:
		if choco > k:
			temp = choco - k
			choco -= temp
			eat += temp
			i -= temp
		else:
			last += 1
			choco += last
			i -= 1
	return eat
(n, k) = map(int, input().strip().split())
print(candy_eaten(n, k))


from math import sqrt, floor

def f(n, k):
	return n - (-3 + round(sqrt(9 + 8 * n + 8 * k))) / 2
(n, k) = [int(x) for x in input().split(' ')]
print(floor(f(n, k)))


(n, k) = map(int, input().split())
flag = 0
total = 0
result = 0
for i in range(1, n):
	total = total + i
	result = total - k
	if result >= 0 and i + result == n:
		print(result)
		flag = 1
		break
if flag == 0:
	print(0)


(n, k) = map(int, input().split())
for i in range(1, n + 1):
	y = (i * (i + 1) - 2 * k) / 2
	if y == n - i:
		print(int(y))
		exit()


import math
(n, k) = map(int, input().split())
d = 2 * n + 3
p = math.sqrt(8 * k + 8 * n + 9)
print(math.ceil((d - p) / 2))


import math

def solve(n, k):
	D = math.sqrt(9 + 8 * n + 8 * k)
	B = 3 + 2 * n
	y1 = int((B + D) / 2)
	y2 = int((B - D) / 2)
	return y1 if y1 < n else y2

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


import math
(n, k) = input().split()
n = int(n)
k = int(k)
solfound = 0
m = 0
x0 = 0
if (3 + 2 * n + math.sqrt((3 + 2 * n) ** 2 - 4 * (n + n ** 2 - 2 * k))) / 2 < n:
	m1 = (3 + 2 * n + math.sqrt((3 + 2 * n) ** 2 - 4 * (n + n ** 2 - 2 * k))) / 2
else:
	m1 = (3 + 2 * n - math.sqrt((3 + 2 * n) ** 2 - 4 * (n + n ** 2 - 2 * k))) / 2
print(int(m1))


(n, k) = map(int, input().split())
count = 0
cands = 0
i = 1
while True:
	count += 1
	cands += i
	i += 1
	if n == count + cands - k:
		print(cands - k)
		break


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
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 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 IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, k) = LI()
		t = 0
		for i in range(1, 10 ** 5):
			t += i
			if t - (n - i) == k:
				rr.append(n - i)
				break
	return JA(rr, '\n')
print(main())


import math
(n, k) = map(int, input().split())
ans_1 = -0.5 * math.sqrt(8 * k + 8 * n + 9) + n + 1.5
ans_2 = 0.5 * math.sqrt(8 * k + 8 * n + 9) + n + 1.5
if 0 <= ans_1 <= n:
	print(int(ans_1))
else:
	print(int(ans_2))


(n, k) = map(int, input().split())
c = 0
count = 0
a = n
while True:
	c += 1
	count += c
	if count - (n - c) == k:
		break
print(n - c)


import math
(n, k) = input().split(' ')
n = int(n)
k = int(k)
variableone = 2 * (n + k)
variabletwo = (-3 + math.sqrt(9 - 4 * 1 * (-1 * variableone))) / 2
variabletwo = int(variabletwo)
y = n - variabletwo
print(y)


(n, k) = list(map(int, input().split()))
for t in range(1, n + 1):
	total = t * (t + 1) // 2
	eat = total - k
	if eat + t == n:
		print(eat)
		break


(n, k) = map(int, input().split())
cur = 0
while (cur + 3) * cur <= 2 * n + 2 * k:
	cur = cur + 1
print(n - cur + 1)


import atexit
import io
import sys
R = lambda : map(int, input().split())
(n, k) = R()
temp = 0
for x in range(int(1000000000.0) + 1):
	if x * (x + 1) // 2 - (n - x) == k:
		temp = x
		break
print(n - temp)


import math
(n, k) = map(int, input().split())
x = math.sqrt(9 + 8 * (n + k)) // 2 - 1
print(int(n - x))


import math
(n, k) = map(int, input().split())
roota = (2 * n + 3 + math.sqrt(8 * n + 8 * k + 9)) // 2
rootb = (2 * n + 3 - math.sqrt(8 * n + 8 * k + 9)) // 2
print(int(rootb))


(n, k) = [int(c) for c in input().split()]
lim = 10 ** 10
val_list = []
val = 0
cnt = 1
while val < lim:
	val = int(cnt * (cnt - 1) / 2)
	val_list.append(val)
	cnt += 1
for i in reversed(range(n)):
	if k + i == val_list[n - i]:
		print(i)
		break


import math
MOD = int(998244353)
n = list(map(int, input().split(' ')))
ans = (2 * n[0] + 3 - int(math.sqrt(8 * (n[0] + n[1]) + 9))) // 2
print(ans)


def BinarSearch(low, up, sum, last):
	mid = low + (up - low) // 2
	if (1 + mid) * mid // 2 - (last - mid) == sum:
		return last - mid
	elif (1 + mid) * mid // 2 - (last - mid) > sum:
		return BinarSearch(low, mid, sum, last)
	elif (1 + mid) * mid // 2 - (last - mid) < sum:
		return BinarSearch(mid, up, sum, last)
(n, k) = map(int, input().split())
print(BinarSearch(1, n, k, n))


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(n, k) = (int(i) for i in input().split())
le = 0
ri = n
while le < ri:
	mid = (le + ri) // 2
	if mid * (mid + 1) // 2 - (n - mid) == k:
		le = mid
		break
	elif mid * (mid + 1) // 2 - (n - mid) < k:
		le = mid + 1
	else:
		ri = mid
print(n - le)


import math
(n, m) = map(int, input().split())
x = (-3 + int(math.sqrt(9 + 8 * (n + m)))) // 2
print(n - x)


s = input().split()
n = int(s[0])
k = int(s[1])
r = 1
e = 0
i = 2
while k + n - (i - 1) != r:
	r += i
	i += 1
print(r - k)


(n, k) = map(int, input().split())
n2 = 100000
ans = 0
n3 = int(k ** 0.5) - 2
for i in range(max(0, n3 - 2), n2):
	temp = (i + 1) * i / 2
	if temp - n + i == k:
		ans = n - i
		break
print(ans)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(n, k) = map(int, input().split())
print(int((2 * n + 3 - (8 * n + 8 * k + 9) ** (1 / 2)) // 2))


import sys
import math
(n, k) = list(map(int, sys.stdin.readline().strip().split()))
a = (2 * n + 3 - math.sqrt((2 * n + 3) ** 2 - 4 * (n ** 2 + n - 2 * k))) // 2
print(int(a))


(n, k) = map(int, input().split())
left = 0
right = n + 1
while left < right - 1:
	middle = (left + right) // 2
	gived = middle * (middle + 1) // 2
	eated = n - middle
	if gived - eated > k:
		right = middle
	else:
		left = middle
print(n - left)


from math import *
(n, k) = map(int, input().split())
i = 1
c = 2 * (n + k)
D = 9 + 4 * c
x = (-3 + sqrt(D)) / 2
X = int(x)
print(n - X)


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


(a, b) = input().split(' ')
n = int(a)
k = int(b)
x = (2 * (k + n) + 2.25) ** 0.5 - 1.5
print(int(n - x))


(x, y) = map(int, input().strip().split())
op = (-3 + pow(9 + 2 * 4 * (x + y), 0.5)) // 2
print(int(x - op))


import math
(a, b) = map(int, input().split())
sum = a * (a + 1) // 2
candies = 0
i = a
y = sum - b
x = 2 * a + 3 - math.sqrt((2 * a + 3) ** 2 - 8 * y)
x = x // 2
print(int(x))


(movimentos, doces_final) = map(int, input().split())
(left, right) = (0, movimentos + 1)
while left < right - 1:
	media = (left + right) // 2
	cedidos = media * (media + 1) // 2
	comidos = movimentos - media
	if cedidos - comidos > doces_final:
		right = media
	else:
		left = media
print(movimentos - left)


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

def mafia():
	pom = [int(x) for x in input().split()]
	n = pom[0]
	c = pom[1]
	po = 1
	ko = n
	sr = (po + ko) // 2
	while po != ko:
		if wzor(sr) - (n - sr) >= c:
			ko = sr
		else:
			po = sr + 1
		sr = (po + ko) // 2
	print(int(wzor(po) - c))
mafia()


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

def solve1():
	(n, k) = list(map(lambda x: int(x), input().split()))
	m = maximum_candies_after_n_movies(n)
	current_candies = n
	eaten_candies = 0
	while m != k:
		m = m - current_candies - 1
		current_candies -= 1
		eaten_candies += 1
	print(eaten_candies)

def solve():
	(n, k) = list(map(lambda x: int(x), input().split()))
	upper_bound = n
	lower_bound = 0
	while upper_bound > lower_bound:
		if upper_bound == lower_bound + 1:
			u_c = maximum_candies_after_n_movies(upper_bound)
			if u_c == k:
				print(n - upper_bound)
				break
		middle = (upper_bound + lower_bound) // 2
		m_candies = maximum_candies_after_n_movies(middle) - (n - middle)
		if m_candies == k:
			print(n - middle)
			break
		elif m_candies < k:
			lower_bound = middle
		else:
			upper_bound = middle
solve()


from math import *
l = [int(i) for i in input().split()]
(n, k) = (l[0], l[1])
x_1 = (2 * n + 3 - sqrt(8 * n + 9 + 8 * k)) / 2
x_2 = (2 * n + 3 + sqrt(8 * n + 9 + 8 * k)) / 2
if x_1 >= 0 and x_1 - round(x_1) == 0:
	print(round(x_1))
else:
	print(round(x_2))


import math
(N, K) = list(map(int, input().split()))
Find = math.sqrt(1 + 8 * (N + K))
if int((-1 + Find) / 2) < 0:
	print(N - int((1 + Find) / 2))
else:
	print(N - int((-1 + Find) / 2))


(a, b) = map(int, input().split())
(m, n, l, s) = (0, 0, [], 0)
c = 0
while True:
	c = c + 1
	s = s + c
	m = m + 1
	if s - (a - m) == b:
		break
print(a - m)


(n, k) = map(int, input().split())
l = 0
h = n
ans = -1
while l <= h:
	mid = (l + h) // 2
	if mid * (mid + 3) == 2 * k + 2 * n:
		ans = mid
		break
	elif mid * (mid + 3) > 2 * k + 2 * n:
		h = mid - 1
	elif mid * (mid + 3) < 2 * k + 2 * n:
		l = mid + 1
print(n - ans)


(n, k) = input().split()
n = int(n)
k = int(k)
ini = 1
fim = n
while ini <= fim:
	med = (ini + fim) // 2
	res = med * (med + 1) / 2 - (n - med)
	if res == k:
		print(n - med)
		break
	elif res > k:
		fim = med - 1
	else:
		ini = med + 1


(n, k) = map(int, input().split())
(low, high) = (0, n)
cnt = 0
diff = n * (n + 1) // 2 - k
while True:
	if high == low:
		print(low)
		break
	mid = (low + high) // 2
	if mid + mid * (2 * n - mid + 1) // 2 < diff:
		low = mid + 1
	else:
		high = mid


(a, b) = map(int, input().split())
if b == a * (a + 1) // 2:
	print(0)
else:
	c = 0
	for x in range(a):
		c += x + 1
		if c - (a - x - 1) == b:
			break
	print(a - x - 1)


import math
(n, k) = input().split()
n = int(n)
k = int(k)
a = 1
b = -(3 + 2 * n)
c = n + n ** 2 - 2 * k
delta = b ** 2 - 4 * a * c
x_1 = (-b + math.sqrt(delta)) / (2 * a)
x_2 = (-b - math.sqrt(delta)) / (2 * a)
if 0 <= x_1 and x_1 <= n:
	print(int(x_1))
else:
	print(int(x_2))


(n, k) = map(int, input().split())
m = 0
while m * (m + 1) // 2 - (n - m) != k:
	m += 1
ans = n - m
print(ans)


a = [int(i) for i in input().split()]
n = a[0]
k = a[1]
i = 1
count = 0
cursum = 0
while count < n:
	if cursum < k:
		cursum += i
	else:
		break
	count += 1
	i += 1
count += cursum - k
if n == count:
	print(cursum - k)
else:
	ans = cursum - k
	extra = 0
	while count < n:
		extra += i
		count += i + 1
		i += 1
	print(ans + extra)


import collections
import math
(n, k) = [int(x) for x in input().split(' ')]
(start, end) = (1, n)
while start <= end:
	mid = start + (end - start) // 2
	remaining = mid * (mid + 1) // 2
	if remaining - (n - mid) == k:
		print(n - mid)
		break
	if remaining - (n - mid) > k:
		end = mid - 1
	else:
		start = mid + 1


(n, k) = map(int, input().split())
c = 0
t = 1
while t * (t + 1) / 2 != k + n - t:
	t += 1
print(n - t)


(n, k) = map(int, input().split())
ans = k
left = 0
right = n
while left <= right:
	mid = (left + right) // 2
	sm = mid * (mid + 1) // 2
	sm = sm - (n - mid)
	if sm == k:
		print(n - mid)
		break
	elif sm < k:
		left = mid + 1
	else:
		right = mid - 1


import math
inputs = input().split()
n = int(inputs[0])
k = int(inputs[1])
x = n - (math.sqrt(9 + 8 * (k + n)) - 3) / 2
print(int(x))


(x, y) = map(int, input().split())
if x == 1 and y == 1:
	print(0)
else:
	for i in range(1, x + 1):
		v = i * (i + 1) // 2
		if v >= y:
			k = v - y
			if k + i == x:
				print(k)
				break