You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1 through infinity from left to right. 

Obviously, there is not enough sand on the beach, so you brought n packs of sand with you. Let height h_{i} of the sand pillar on some spot i be the number of sand packs you spent on it. You can't split a sand pack to multiple pillars, all the sand from it should go to a single one. There is a fence of height equal to the height of pillar with H sand packs to the left of the first spot and you should prevent sand from going over it. 

Finally you ended up with the following conditions to building the castle:  h_1 ≤ H: no sand from the leftmost spot should go over the fence;  For any $i \in [ 1 ; \infty)$ |h_{i} - h_{i} + 1| ≤ 1: large difference in heights of two neighboring pillars can lead sand to fall down from the higher one to the lower, you really don't want this to happen;  $\sum_{i = 1}^{\infty} h_{i} = n$: you want to spend all the sand you brought with you. 

As you have infinite spots to build, it is always possible to come up with some valid castle structure. Though you want the castle to be as compact as possible. 

Your task is to calculate the minimum number of spots you can occupy so that all the aforementioned conditions hold.


-----Input-----

The only line contains two integer numbers n and H (1 ≤ n, H ≤ 10^18) — the number of sand packs you have and the height of the fence, respectively.


-----Output-----

Print the minimum number of spots you can occupy so the all the castle building conditions hold.


-----Examples-----
Input
5 2

Output
3

Input
6 8

Output
3



-----Note-----

Here are the heights of some valid castles:   n = 5, H = 2, [2, 2, 1, 0, ...], [2, 1, 1, 1, 0, ...], [1, 0, 1, 2, 1, 0, ...]  n = 6, H = 8, [3, 2, 1, 0, ...], [2, 2, 1, 1, 0, ...], [0, 1, 0, 1, 2, 1, 1, 0...] (this one has 5 spots occupied) 

The first list for both cases is the optimal answer, 3 spots are occupied in them.

And here are some invalid ones:  n = 5, H = 2, [3, 2, 0, ...], [2, 3, 0, ...], [1, 0, 2, 2, ...]  n = 6, H = 8, [2, 2, 2, 0, ...], [6, 0, ...], [1, 4, 1, 0...], [2, 2, 1, 0, ...]

Difficulty: HARD

Solutions:
def gs(x):
	return x * (x + 1) // 2

def gs2(x):
	if x % 2 == 0:
		cr = 0
	else:
		cr = x // 2 + 1
	cr += h * x
	cr += (x // 2 + 1) * (x // 2)
	return cr
r = 10 ** 18 + 7
(n, h) = [int(i) for i in input().strip().split()]
l = 0
r = min(h + 1, r)
while r - l > 1:
	m = (l + r) // 2
	if gs(m) <= n:
		l = m
	else:
		r = m
tr = l
n -= gs(l)
if n >= h:
	n -= h
	tr += 1
	l = 0
	r = 10 ** 18 + 7
	while r - l > 1:
		m = (l + r) // 2
		if gs2(m) <= n:
			l = m
		else:
			r = m
	tr += l
	n -= gs2(l)
if n > 0:
	tr += 1
print(tr)


import math

def g(a, b):
	return (a + b) * (b - a + 1) / 2

def f(a, b):
	return g(a, b) + g(1, b)
(n, h) = map(int, input().strip().split())
if h * (1 + h) / 2 >= n:
	l = int(1)
	r = int(h)
	while r > l:
		mid = int((l + r) / 2)
		if mid * (1 + mid) < n * 2:
			l = mid + 1
		else:
			r = mid
	print(int(l))
else:
	l = h
	r = 1500000000
	while r > l:
		mid = int((l + r) / 2)
		if f(h, mid) < n:
			l = mid + 1
		else:
			r = mid
	if n <= g(h, l) + g(1, l - 1):
		print(int(l - h + l))
	else:
		print(int(l - h + l + 1))


(n, h) = map(int, input().split())
sum = (h + h * h) // 2
if sum >= n - h:
	l = 0
	r = h + 1
	while l < r - 1:
		m = (l + r) // 2
		sum = (m + m * m) // 2
		if sum <= n:
			l = m
		else:
			r = m
	sum = (l + l * l) // 2
	ans = l
	if sum < n:
		ans += 1
	print(ans)
else:
	l = h
	r = 100000000000000000000000000
	while l < r - 1:
		m = (l + r) // 2
		sum1 = (m + m * m) // 2
		sum2 = (m - h + 1) * (h + m) // 2
		if sum1 + sum2 <= n:
			l = m
		else:
			r = m
	sum = (l + l * l) // 2 + (l - h + 1) * (h + l) // 2
	ans = l + l - h + 1
	n = n - sum
	if n >= l + 1:
		ans = ans + 1
		n = n - (l + 1)
	if n > 0:
		ans = ans + 1
	print(ans)


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

def solve(mid):
	sum_n = mid * (mid + 1) // 2
	return sum_n <= n
ok = 0
ng = h + 1
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	if solve(mid):
		ok = mid
	else:
		ng = mid
if h != ok:
	ans = ok
	nokori = n - ans * (ans + 1) // 2
	if nokori > 0:
		ans += 1
	print(ans)
else:
	ans = ok
	nokori = n - ans * (ans + 1) // 2
	while True:
		if 10 ** 6 * 2 * h + (10 ** 6) ** 2 <= nokori:
			nokori -= 10 ** 6 * 2 * h + (10 ** 6) ** 2
			ans += 2 * 10 ** 6
			h += 10 ** 6
			continue
		if h + 1 + h <= nokori:
			nokori -= h + 1 + h
			ans += 2
			h += 1
		else:
			ans += -(-nokori // h)
			break
	print(ans)


(n, H) = list(map(int, input().split()))
tmp = (H + 1) * H >> 1
if n < tmp:
	(l, r) = (0, 1000000000000000000)
	while l < r:
		mid = l + r >> 1
		tmp = (mid + 1) * mid >> 1
		if n > tmp:
			l = mid + 1
		else:
			r = mid
	print(r)
else:
	(l, r) = (H, 1000000000000000000)
	while l < r:
		mid = l + r >> 1
		if mid + H & 1:
			T = mid + H >> 1
			tmp = ((T + H) * (T - H + 1) >> 1) + (T * (T + 1) >> 1)
		else:
			T = mid + H >> 1
			tmp = ((T + H) * (T - H + 1) >> 1) + (T * (T - 1) >> 1)
		if n > tmp:
			l = mid + 1
		else:
			r = mid
	print(r)


(N, H) = map(int, input().split())
ans = N
ok = 1
ng = H + 1
while ng - ok > 1:
	md = (ok + ng) // 2
	K = md * (md + 1) // 2
	if K <= N:
		L = N - K
		X = L // md
		if L % md != 0:
			X += 1
		if ans > md + X:
			ans = md + X
		ok = md
	else:
		ng = md
if H * (H + 1) // 2 > N:
	print(ans)
	exit(0)
ok = H
ng = N
while ng - ok > 1:
	md = (ok + ng) // 2
	K = md * (md + 1) // 2 + md * (md - 1) // 2 - H * (H - 1) // 2
	if K <= N:
		L = N - K
		X = md + md - H + L // md
		if L % md != 0:
			X += 1
		if ans > X:
			ans = X
		ok = md
	else:
		ng = md
print(ans)


from math import *
(n, h) = (int(x) for x in input().split(' '))
if (h + 1) * h // 2 >= n:
	a = int(ceil((-1 + sqrt(1 + 8 * n)) / 2))
	if (a + 1) * a // 2 >= n:
		print(a)
	else:
		print(a + 1)
else:
	n -= int((h + 1) * h / 2)
	n -= h
	if n > 0:
		a = int((-2 * h - 1 + sqrt((2 * h + 1) * (2 * h + 1) + 4 * n)) / 2)
		if (2 * h + 1 + a) * a >= n:
			print(a * 2 + h + 1)
		elif (2 * h + 1 + a) * a + h + a + 1 >= n:
			print(a * 2 + 1 + h + 1)
		else:
			print(a * 2 + 2 + h + 1)
	else:
		print(h + 1)


T = input().split(' ')
n = int(T[0])
H = int(T[1])
a = 1
b = n

def f(m):
	tot = 42
	if m <= H:
		tot = m * (m + 1) // 2
	else:
		tot = H * (H + 1) // 2
		if (m - H) % 2 == 1:
			mx = H + (m - H) // 2
			tot += 2 * (mx * (mx + 1) // 2 - H * (H - 1) // 2)
			tot -= H
		else:
			mx = H + (m - H) // 2
			tot += 2 * (mx * (mx + 1) // 2 - H * (H - 1) // 2)
			tot -= H
			tot -= mx
	return tot >= n
if n == 1:
	print(1)
else:
	m = (a + b) // 2
	while b - a > 1:
		if f(m):
			b = m
		else:
			a = m
		m = (a + b) // 2
	print(b)


def main():
	(n, H) = map(int, input().split())
	if (1 + H) * H // 2 >= n:
		l = 1
		r = H
		while l < r:
			h = (l + r) // 2 + 1
			if (1 + h) * h // 2 > n:
				r = h - 1
			else:
				l = h
		h = r
		rest = n - (1 + h) * h // 2
		(q, r) = divmod(rest, h)
		ans = h + q + (1 if r != 0 else 0)
	else:
		l = H
		r = n
		while l < r:
			h = (l + r) // 2 + 1
			if (H + h - 1) * (h - H) // 2 + (1 + h) * h // 2 > n:
				r = h - 1
			else:
				l = h
		h = r
		rest = n - ((H + h - 1) * (h - H) // 2 + (1 + h) * h // 2)
		(q, r) = divmod(rest, h)
		ans = h - H + h + q + (1 if r != 0 else 0)
	print(ans)
main()


def S(l):
	return l * (l + 1) // 2

def f(l, h):
	if l <= h:
		return S(l)
	s = S(h)
	l -= h
	s += l * h
	s += S(l // 2) + S(l // 2 - (1 - l % 2))
	return s
(n, H) = map(int, input().split())
l = 0
r = n + 1
while r - l > 1:
	md = (l + r) // 2
	if f(md, H) >= n:
		r = md
	else:
		l = md
print(r)


from sys import stdin

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

def g(n):
	(lo, hi) = (1, n)
	while lo < hi:
		mid = (lo + hi) // 2
		if f(mid) < n:
			lo = mid + 1
		else:
			hi = mid
	return lo

def ar(a, b, n):
	return (a + b) * n // 2

def total(n, H):
	if n < H:
		return ar(n, 1, n)
	return ar(n, n - H + 1, H) + f(n - H + 1)

def main():
	for line in stdin.readlines():
		(n, H) = [int(x) for x in line.split()]
		(lo, hi) = (1, n)
		while lo < hi:
			mid = (lo + hi) // 2
			if total(mid, H) < n:
				lo = mid + 1
			else:
				hi = mid
		print(lo)
main()


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


import math

def sum(x):
	return x * (x + 1) // 2

def check(x):
	ans = 0
	if x <= h:
		ans = sum(x)
	else:
		md = (x - h + 2) / 2.0
		if md - math.floor(md) == 0:
			ans = sum(h + md - 1) - sum(h - 1) + sum(x - md)
		else:
			md = math.floor(md)
			ans = sum(h + md - 1) - sum(h - 1) + sum(h + md - 1)
	if ans < n:
		return 1
	else:
		return 0
(n, h) = input().strip().split()
n = int(n)
h = int(h)
l = 0
r = 2000000000
while l < r:
	mid = (l + r) // 2
	if check(mid) != 0:
		l = mid + 1
	else:
		r = mid
if check(r) == 0:
	ans1 = r
else:
	ans1 = r + 1
print(ans1)


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

def f(x):
	return x * (x + 1) // 2 if x < h else h * (h + 1) // 2 + (x - h) * h + (x - h) / 2 * ((x - h) / 2) - 0.25 * ((x - h) % 2)
l = 1
r = n
while l < r:
	mid = (l + r) // 2
	if f(mid) >= n:
		r = mid
	else:
		l = mid + 1
print(l)


(n, H) = map(int, input().split())
(left, right) = (0, n)
limit = n + (H - 1) * H // 2

def check(t):
	if t <= H:
		return t * (t + 1) // 2 >= n
	if (t + H - 1) % 2:
		return (t + H) ** 2 // 4 >= limit
	else:
		return ((t + H) ** 2 - 1) // 4 >= limit
while True:
	if right - left <= 1:
		break
	tmp = (left + right) // 2
	if check(tmp):
		right = tmp
	else:
		left = tmp
print(right)


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

def get(x):
	if x <= k:
		return x * (x + 1) // 2
	res = k * x - k * (k - 1) // 2
	sz = x - k - 1
	if sz % 2 == 0:
		cnt = sz // 2
		res += (2 + sz) * cnt // 2
	else:
		cnt = sz // 2 + 1
		res += (1 + sz) * cnt // 2
	return res
l = 0
r = 10 ** 18
while r - l > 1:
	m = l + (r - l) // 2
	if get(m) >= n:
		r = m
	else:
		l = m
print(r)


def parser():
	while 1:
		data = list(input().split(' '))
		for number in data:
			if len(number) > 0:
				yield number
input_parser = parser()

def get_word():
	global input_parser
	return next(input_parser)

def get_number():
	data = get_word()
	try:
		return int(data)
	except ValueError:
		return float(data)
from math import *

def check(k, n, H, maxx):
	h = min(k, H)
	h = min(h, maxx)
	summa = 0
	if h % 2 == k % 2:
		c = int((h + k) // 2)
		summa += int(c * (c + 1) // 2)
		summa += int((c - h) * h + (c - h) * (c - h - 1) // 2)
	else:
		c = int((h + k - 1) // 2)
		summa += int(c * (c + 1) // 2)
		summa += int((c + 1 - h) * h + (c - h) * (c - h + 1) // 2)
	if summa >= n:
		return True
	else:
		return False

def find(n, H, maxx):
	l = 0
	r = 1000000000000000
	while r - l > 1:
		current = int((l + r) // 2)
		if check(current, n, H, maxx):
			r = current
		else:
			l = current
	return r
n = int(get_number())
H = int(get_number())
maxx = int((int(sqrt(8 * n + 1)) + 1) // 2)
print(find(n, H, maxx))


from bisect import bisect_left, bisect_right
Inf = int(1e+18) + 7

def tuple_input(type):
	return map(type, input().strip().split())
(n, H) = tuple_input(int)
(lo, hi) = (0, Inf)
while lo < hi:
	x = (lo + hi) // 2
	if n < x * (x + 1) // 2:
		hi = x
	else:
		lo = x + 1
h0 = min(H, lo - 1)
r = n - h0 * (h0 + 1) // 2
res1 = h0 + r // h0 + (1 if r % h0 else 0)
(lo, hi) = (H, Inf)
while lo < hi:
	x = (lo + hi) // 2
	m = x * x - H * (H - 1) // 2
	if n < m:
		hi = x
	else:
		lo = x + 1
hp = max(H + 1, lo - 1)
area = hp * hp - H * (H - 1) // 2
if area > n:
	print(res1)
	exit(0)
r = n - area
res2 = 2 * hp - H + r // hp + (1 if r % hp else 0)
print(min(res1, res2))


(N, H) = list(map(int, input().split()))
ok = N
ng = 0
while ok - ng > 1:
	mid = (ok + ng) // 2
	if mid <= H:
		sum = mid * (mid + 1) // 2
		if sum < N:
			ng = mid
		else:
			ok = mid
	else:
		sum = H * (H + 1) // 2
		rest = mid - H
		sum += rest * H
		if rest % 2 == 1:
			height = (rest - 1) // 2
			add = height * (height + 1) // 2
			sum += add * 2
		else:
			bottom = rest // 2
			add = bottom * (bottom + 1) // 2
			sum += add * 2
			sum -= bottom
		if sum < N:
			ng = mid
		else:
			ok = mid
print(ok)


from math import *
(n, h) = map(int, input().split())

def sm(x):
	steps = x // 2 + x % 2
	return (x - (steps - 1)) * steps

def is_ok(x):
	sum = 0
	if x <= h:
		sum = x * (x + 1) // 2
	else:
		sum = h
		x -= 1
		sum += sm(x + h) - h * (h + 1) // 2
	if sum >= n:
		return True
	else:
		return False
l = 1
r = 10 ** 18
while l < r:
	mid = (l + r) // 2
	if is_ok(mid):
		r = mid
	else:
		l = mid + 1
print(l)


def sumi(a, b):
	return (a + b) * (b - a + 1) // 2

def main():
	(n, H) = list(map(int, input().split()))
	volh = (H + 1) * H // 2
	if n < volh:
		low = 0
		high = n + 1
		while high - low > 1:
			mid = low + (high - low) // 2
			vol = (mid + 1) * mid // 2
			if vol >= n:
				high = mid
			else:
				low = mid
		print(high)
		return
	low = 0
	high = n + 1
	while high - low > 1:
		mid = low + (high - low) // 2
		twoi = mid - H + 2
		if twoi % 2 != 0:
			peakh = H + (twoi - 3) // 2
			vol = sumi(H, peakh) + sumi(1, peakh)
		else:
			peakh = H + (twoi - 2) // 2
			vol = sumi(H, peakh) + sumi(1, peakh - 1)
		if vol >= n:
			high = mid
		else:
			low = mid
	print(high)
main()


import math
(n, H) = map(int, input().split())
k = (-1.0 + math.sqrt(1 + 8 * n)) / 2.0
a = int(k)
if a * (a + 1) / 2 != n:
	a += 1
if int(k) <= H:
	print(a)
else:
	n += H * (H - 1) // 2
	q1 = math.sqrt(n)
	sq1 = int(q1)
	if sq1 * sq1 < n:
		sq1 += 1
	ans1 = sq1 + sq1 - 1
	ans1 -= H - 1
	q2 = (-1 + math.sqrt(1 + 4 * n)) / 2
	sq2 = int(q2)
	if sq2 * (sq2 + 1) < n:
		sq2 += 1
	ans2 = sq2 + sq2
	ans2 -= H - 1
	ans = min(ans1, ans2)
	print(ans)


from decimal import *
line = input().strip().split(' ')
n = Decimal(line[0])
h = Decimal(line[1])
th = h * (h + 1) / 2
if n <= th:
	v = Decimal.sqrt(Decimal(0.25) + 2 * n) - Decimal(0.5)
	print(v.quantize(Decimal('1.'), rounding=ROUND_CEILING))
else:
	n += h * (h - 1) / 2
	sqrt = 2 * Decimal.sqrt(n)
	quantize = sqrt.quantize(Decimal('1.'), rounding=ROUND_CEILING)
	print(quantize - h)


(n, h) = input().split(' ')
n = int(n)
h = int(h)
l = 1
r = 1000000000000000000
while l < r:
	k = (l + r) // 2
	u = 0
	if k <= h:
		u = k * (k + 1) // 2
	else:
		u = h * (h + 1) // 2
		u += h * (k - h)
		d = k - h
		if d % 2 == 0:
			u += d * d // 4
		else:
			d //= 2
			u += d * (d + 1)
	if u < n:
		l = k + 1
	else:
		r = k
print(l)


def check(osn):
	global h
	global n
	if osn <= h:
		res = osn * (osn + 1) // 2
	else:
		max_h = (h + osn) // 2
		del_h = max(min(max_h - (osn - max_h), osn), 1)
		res = max_h * max_h - del_h * (del_h - 1) // 2
		if (h + osn) % 2 != 0:
			res += osn - max_h
	if res >= n:
		return True
	return False
(n, h) = map(int, input().split())
l = 1
r = 10 ** 18 + 10
while r - l > 1:
	m = (l + r) // 2
	if check(m):
		r = m
	else:
		l = m
if check(l):
	print(l)
else:
	print(r)


def judge(mid, n, H):
	if mid <= H:
		return mid * (mid + 1) // 2
	right = mid * (mid + 1) // 2
	left = (mid - H + 1) * H + (mid - H + 1) * (mid - H + 1 - 1) // 2
	return left + right - mid

def solve(n, H):
	low = 1
	high = 1000000000000000000
	while True:
		mid = low + high >> 1
		now = judge(mid, n, H)
		if low == mid:
			if now >= n:
				return low + max(0, low - H)
			elif now + low >= n:
				return low + max(0, low - H) + 1
			return high + max(0, high - H)
		if now == n:
			return mid + max(0, mid - H)
		elif now < n:
			low = mid
		elif now > n:
			high = mid
	pass
try:
	while True:
		(n, H) = input().split()
		n = int(n)
		H = int(H)
		print(solve(n, H))
except EOFError:
	pass


from math import *
(n, h) = input().split()
n = int(n)
h = int(h)
ans = 0
if n == h * (h + 1) / 2:
	ans = h
elif n <= h * (h + 1) / 2:
	a = int((sqrt(1 + 8 * n) - 1) // 2)
	if n == a * (a + 1) / 2:
		ans = a
	else:
		ans = a + 1
n = n - h * (h + 1) / 2
if n >= 0 and n < h:
	if n == 0:
		ans = h
	else:
		ans = h + 1
elif n >= 0:
	n = n + h
	b = 2 * h - 1
	a = int((-b + sqrt(b * b + 4 * n)) // 2)
	n = n - a * (2 * h + (a - 1))
	ans = 2 * a + h - 1
	if n == 0:
		ans = ans + 0
	elif n <= h + a:
		ans = ans + 1
	else:
		ans = ans + 2
print(ans)


def f(mid, h):
	if mid <= h:
		return mid * (mid + 1) // 2
	p = (mid - h + 1) // 2
	return (h + h + p - 1) * p // 2 + (mid - p) * (mid - p + 1) // 2
(n, h) = map(int, input().split())
(l, r) = (0, 10000000000)
while l + 1 < r:
	mid = (l + r) // 2
	if f(mid, h) >= n:
		r = mid
	else:
		l = mid
print(r)


def sum(a, b):
	if a > b:
		return sum(b, a)
	n = b - a + 1
	return (a + b) * n // 2
[n, h] = [int(x) for x in input().split()]
l = 0
r = n
while l + 1 < r:
	m = (l + r) // 2
	mx = 0
	if m < h:
		mx = sum(1, m)
	elif m % 2 == h % 2:
		hm = (h + m) // 2
		mx = sum(h, hm) + sum(1, hm - 1)
	else:
		hm = (h + m) // 2
		mx = sum(h, hm) + sum(1, hm)
	if mx >= n:
		r = m
	else:
		l = m
print(r)


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

def triang2(n):
	if n % 2 == 0:
		return n // 2 * (n + 2) // 2
	return ((n + 1) // 2) ** 2

def satisfy(n, b, H):
	return b <= 2 * n and n <= triang(b) - triang(max(0, b - H)) + triang2(max(0, b - H - 1))
(n, H) = list(map(int, input().split()))
b_max = 2 * n
b = b_max
LN = 60
for i in reversed(range(LN + 1)):
	if b - (1 << i) <= 0:
		continue
	if satisfy(n, b - (1 << i), H):
		b -= 1 << i
print(b)


[n, H] = map(int, input().strip().split())

def bsearch(f, xmin, xmax):
	while xmax - xmin > 1:
		xmid = (xmax + xmin) // 2
		if f(xmid):
			xmax = xmid
		else:
			xmin = xmid
	return xmax

def f1(x):
	return 2 * n <= x * (x + 1)
HH = H * (H + 1) // 2

def f2(x):
	r = x - H
	R0 = r // 2
	R1 = (r + 1) // 2
	return n <= HH + H * r + R0 * R1
if n <= HH:
	x = bsearch(f1, 0, H)
else:
	xmin = H
	xmax = H
	while not f2(xmax):
		xmin = xmax
		xmax *= 2
	x = bsearch(f2, xmin, xmax)
print(x)


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


def compute(H, mid):
	if mid <= H:
		return (mid + 1) * mid // 2
	else:
		remain = mid - H + 1
		ret = (H - 1) * H / 2 + H * remain
		t = (mid - H) // 2
		if remain % 2:
			ret += t * t
		else:
			ret += (t + 1) * t
		return ret
(n, H) = map(int, input().split())
left = 1
right = 10 ** 12
while left < right:
	mid = (left + right) // 2
	maxuse = compute(H, mid)
	if maxuse >= n:
		right = mid
	else:
		left = mid + 1
print(right)


(n, H) = map(int, input().split())
l = 0
r = n + 1
while r - l > 1:
	mid = (l + r) // 2
	t = min(mid, H) * (min(mid, H) + 1) // 2
	if mid > H:
		tmid = mid - H
		t += tmid * H
		s = tmid // 2
		t += s * (s + 1)
		if tmid % 2 == 0:
			t -= s
	if t >= n:
		r = mid
	else:
		l = mid
print(r)


def cal(x):
	return (1 + x) * x // 2

def g(x):
	if x % 2 == 0:
		return 2 * cal(x // 2)
	else:
		return cal(x // 2 + 1) + cal(x // 2)

def check2(x, num):
	if g(x) >= num:
		return 1
	return 0
(n, h) = (int(x) for x in input().split(' '))
if cal(h) >= n:
	(lo, hi) = (1, n)
	ans = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		if cal(mid) >= n:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(ans)
else:
	h = h - 1
	n += cal(h)
	(lo, hi) = (1, n)
	ans = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		if g(mid) >= n:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(ans - h)


def solve(n, H):

	def ligma(s):
		return (s * s + s) // 2
	if ligma(H) >= n:
		(lo, hi) = (1, H)
		while lo < hi:
			mid = (lo + hi) // 2
			if ligma(mid) >= n:
				hi = mid
			else:
				lo = mid + 1
		return lo

	def blocks(R):
		k = 1 + (R - H) // 2
		S = (R - H) * k - 2 * ligma(k - 1)
		return ligma(R) - S
	(lo, hi) = (H, n)
	while lo < hi:
		mid = (lo + hi) // 2
		if blocks(mid) >= n:
			hi = mid
		else:
			lo = mid + 1
	return lo
(n, H) = map(int, input().split())
print(solve(n, H))


(n, H) = input().split()
n = int(n)
H = int(H)

def can(m):
	global n, H
	ans = 0
	tt = min(m, H)
	ans += (tt + 1) * tt // 2
	ans += (m - tt) * H
	ost = m - tt
	if ost % 2 == 0:
		up = ost // 2 - 1
		ans += (up + 1) * up
		ans += up + 1
	else:
		up = ost // 2
		ans += (up + 1) * up
	return ans
l = 0
r = n + H
while r - l > 1:
	m = (l + r) // 2
	if can(m) < n:
		l = m
	else:
		r = m
print(r)


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


def parser():
	while 1:
		data = list(input().split(' '))
		for number in data:
			if len(number) > 0:
				yield number
input_parser = parser()

def get_word():
	global input_parser
	return next(input_parser)

def get_number():
	data = get_word()
	try:
		return int(data)
	except ValueError:
		return float(data)
N = get_number()
H = get_number()
if (1 + H) * H // 2 < N:
	L = H - 1
	R = 100000000000000000000000000
	while L + 1 < R:
		mid = (L + R) // 2
		if (1 + mid) * mid // 2 + (H + mid - 1) * (mid - 1 - H + 1) // 2 >= N:
			R = mid
		else:
			L = mid
	ans = R + R - H
	L = H - 1
	R = 100000000000000000000000000
	while L + 1 < R:
		mid = (L + R) // 2
		if (1 + mid) * mid // 2 + (H + mid) * (mid - H + 1) // 2 >= N:
			R = mid
		else:
			L = mid
	if R + R - H + 1 < ans:
		ans = R + R - H + 1
else:
	L = 0
	R = H
	while L + 1 < R:
		mid = (L + R) // 2
		if (1 + mid) * mid // 2 >= N:
			R = mid
		else:
			L = mid
	ans = R
print(ans)


def calc(x, h):
	if x <= h:
		return x * (x + 1) // 2
	p = (x - h + 1) // 2
	return (2 * h + p - 1) * p // 2 + (x - p) * (x - p + 1) // 2
(n, h) = map(int, input().split())
ok = 10000000000
ng = 0
while ok - ng > 1:
	m = (ok + ng) // 2
	if calc(m, h) >= n:
		ok = m
	else:
		ng = m
print(ok)


import math
(n, h) = map(int, input().strip().split(' '))
x = h * (h + 1) // 2
if x == n:
	print(h)
elif n == 1:
	print(1)
elif n < x:
	low = 1
	high = h
	ans = 10 ** 20
	while low <= high:
		mid = (low + high) // 2
		temp = mid * (mid + 1) // 2
		if temp == n:
			ans = mid
			break
		if temp < n:
			low = mid + 1
		else:
			ans = min(ans, mid)
			high = mid - 1
	print(ans)
else:
	low = h
	high = 10 ** 10
	ans = -10 ** 20
	while low <= high:
		mid = (low + high) // 2
		temp = (mid + 1) * mid // 2 + max(0, (mid + 1) * mid // 2 - h * (h + 1) // 2 + h - mid)
		if temp <= n:
			low = mid + 1
			ans = mid
		else:
			high = mid - 1
	mid = ans
	n -= (mid + 1) * mid // 2 + max(0, (mid + 1) * mid // 2 - h * (h + 1) // 2 + h - mid)
	if n != 0:
		ans += n // mid
		n -= n // mid * mid
		if n != 0:
			ans += 1
	print(ans + mid - h)


(n, h) = [int(x) for x in input().split()]
l = -1
r = n + 1
m = (l + r) // 2
while r - l > 1:
	if m <= h:
		v = m * (m + 1) // 2
	else:
		v = m * (m + 1) // 2 - h * (h - 1) // 2 + m * (m - 1) // 2
	if v <= n:
		l = m
	else:
		r = m
	m = (l + r) // 2
if l < h:
	v = l * (l + 1) // 2
	print(l + (n - v) // l + ((n - v) % l != 0))
	exit()
else:
	v = l * (l + 1) // 2 - h * (h - 1) // 2 + l * (l - 1) // 2
	print(l - h + l + (n - v) // l + ((n - v) % l != 0))


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

def g(d):
	if d < h:
		return d * (d + 1) // 2
	d = d - h + 1
	dd = d // 2
	p = 2 * ((h - 1) * dd + dd * (dd + 1) // 2)
	if d % 2 == 1:
		p += h - 1 + dd + 1
	return (h - 1) * (h - 1 + 1) // 2 + p
a = 0
b = 10 ** 20
while a != b:
	c = (a + b) // 2
	if n <= g(c):
		b = c
	else:
		a = c + 1
print(a)


(n, H) = map(int, input().split())
m = n
n += H * (H - 1) / 2
l = H
r = 2000000000000000000
while l + 1 < r:
	mid = (l + r) // 2
	heap = mid // 2
	kek = 0
	if mid % 2 == 1:
		kek += heap * (heap + 1)
		kek += heap + 1
	else:
		kek += heap * (heap + 1)
	if kek >= n:
		r = mid
	else:
		l = mid
a = 0
b = H
while a + 1 < b:
	mid = (a + b) // 2
	kek = mid * (mid + 1) // 2
	if kek >= m:
		b = mid
	else:
		a = mid
if H * (H + 1) // 2 >= m:
	print(b)
	exit()
print(r - H + 1)


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

def can(x):
	if x <= H:
		return n <= (1 + x) * x // 2
	L = x + H - 1
	h = L // 2
	s = (1 + h) * h
	if L % 2 == 1:
		s += h + 1
	s -= H * (H - 1) // 2
	return n <= s
(m, M) = (0, int(1e+18) + 5)
while M - m > 1:
	mid = m + (M - m) // 2
	if can(mid):
		M = mid
	else:
		m = mid
print(M)


(n, H) = map(int, input().split())
mx = int((1 + 8 * n) ** 0.5)
while (mx + 1) * (mx + 1) <= 1 + 8 * n:
	mx += 1
mx = (mx - 1) // 2
if mx <= H:
	if (1 + mx) * mx // 2 < n:
		mx += 1
	print(mx)
	exit()
else:
	mx = H
	n -= (1 + H) * H // 2

def f(moves, mx):
	res = moves * mx
	add = (moves - 1) // 2
	res += (add + 1) * add
	if moves % 2 == 0:
		res += add + 1
	return res
l = 1
r = 10 ** 18
while l < r - 1:
	m = (l + r) // 2
	if f(m, mx) < n:
		l = m
	else:
		r = m
if f(l, mx) >= n:
	r = l
print(mx + r)


def check(p):
	return p * (p + 1) // 2 >= min(n, H * (H + 1) // 2)

def binSearch(a, b):
	(left, right) = (a - 1, b + 1)
	while right - left > 1:
		mid = (left + right) // 2
		if check(mid):
			right = mid
		else:
			left = mid
	return right
(n, H) = map(int, input().split())
b = binSearch(1, H)
if n <= H * (H + 1) // 2:
	print(b)
	exit()
S_0 = H * (H - 1) // 2

def check(p):
	return S_0 + (2 * H + p - 1) * p >= n

def binSearch(a, b):
	(left, right) = (a - 1, b + 1)
	while right - left > 1:
		mid = (left + right) // 2
		if check(mid):
			right = mid
		else:
			left = mid
	return right
b_1 = binSearch(1, 10 ** 10)
delta = S_0 + (2 * H + b_1 - 1) * b_1 - n
print(b - 1 + 2 * b_1 - (delta >= b + b_1 - 1))


def max_number_of_packs(number_of_spots, fence_height):
	if number_of_spots > fence_height:
		k = (number_of_spots - fence_height) // 2 + fence_height
		l = number_of_spots - k
		return k * (k + 1) // 2 + l * (l + 1) // 2 + l * (fence_height - 1)
	else:
		return number_of_spots * (number_of_spots + 1) // 2

def binary_search(left, right, number_of_packs, fence_height):
	if left >= right - 1:
		return right
	middle = (left + right) // 2
	max_packs = max_number_of_packs(middle, fence_height)
	if max_packs < number_of_packs:
		return binary_search(middle, right, number_of_packs, fence_height)
	else:
		return binary_search(left, middle, number_of_packs, fence_height)
(n, h) = map(int, input().split())
print(binary_search(0, 10 ** 18, n, h))


(n, h) = input().split()
n = int(n)
h = int(h)
if n > (1 + h) * h // 2:
	l = h
	r = n + 1

	def check(v):
		if (h + v) * (v - h + 1) // 2 + (1 + v) * v // 2 - v > n:
			return False
		return True
	while l < r:
		mid = (l + r) // 2 + 1
		if check(mid):
			l = mid
		else:
			r = mid - 1
	n -= (h + l) * (l - h + 1) // 2
	ans = l - h + 1
	n -= (1 + l) * l // 2 - l
	ans += l - 1
	ans += (n + l - 1) // l
	print(ans)
else:
	l = 1
	r = h

	def check(mid):
		return (1 + mid) * mid // 2 >= n
	while l < r:
		mid = (l + r) // 2
		if check(mid):
			r = mid
		else:
			l = mid + 1
	print(l)


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

def f(k, n, h):
	r = 0
	if k <= h:
		r = k * (k + 1) // 2
	else:
		bb = k - h + 1
		zz = bb // 2
		r = h * (h + 1) // 2 - h + bb * h + zz * bb - zz * (zz + 1)
	return r
l = 0
r = n
while l + 1 < r:
	k = l + (r - l) // 2
	cnt = f(k, n, h)
	if cnt < n:
		l = k
	else:
		r = k
if f(l, n, h) < n:
	l += 1
print(l)


def bin(f, l, val, h):
	mid = int((f + l) / 2)
	p = mid * (mid + 1) - int(h * (h - 1) / 2) - mid
	if p <= val and val < (mid + 1) * (mid + 2) - int(h * (h - 1) / 2) - mid - 1:
		return mid
	elif val >= p:
		f = mid + 1
		return bin(f, l, val, h)
	elif val < p:
		l = mid - 1
		return bin(f, l, val, h)
	else:
		return mid

def binS(f, l, val):
	mid = int((f + l) / 2)
	p = mid * (mid + 1) / 2
	if p <= val and val < (mid + 1) * (mid + 2) / 2:
		return mid
	elif val >= p:
		f = mid + 1
		return binS(f, l, val)
	elif val < p:
		l = mid - 1
		return binS(f, l, val)
(n, h) = input().split()
n = int(n)
h = int(h)
an = binS(0, pow(10, 12), n)
if an <= h:
	if an == 1414213560 - 1:
		an += 1
	if int(an * (an + 1) / 2) == n:
		print(an)
	else:
		print(an + 1)
else:
	an = bin(0, pow(10, 12), n, h)
	if int(an * (an + 1)) - int(h * (h - 1) / 2) < n:
		print(an * 2 - h + 2)
	elif an * (an + 1) - int(h * (h - 1) / 2) - an == n:
		print(2 * an - h)
	else:
		print(2 * an - h + 1)


import math

def cal1(x):
	res = 0
	res = x * (x + 1) // 2
	tot = H + x - 1
	leng = x - H
	res += tot * leng // 2
	return res

def cal2(x):
	res = x * (x + 1) // 2
	return res
a = input().split()
n = int(a[0])
H = int(a[1])
ne = cal1(H)
if n >= ne:
	l = 0
	r = n
	while l < r:
		mid = (l + r + 1) // 2
		if n >= cal1(mid):
			tmp = mid
			l = mid
		else:
			r = mid - 1
	ans = 2 * tmp - H
	if n > cal1(tmp):
		ans += math.ceil((n - cal1(tmp)) / tmp)
else:
	l = 0
	r = n
	while l < r:
		mid = (l + r + 1) // 2
		if n >= cal2(mid):
			tmp = mid
			l = mid
		else:
			r = mid - 1
	ans = tmp
	if n > cal2(tmp):
		ans += math.ceil((n - cal2(tmp)) / tmp)
print(ans)


import sys
import math

def s(x):
	return x * (x + 1) // 2

def f(h2, r2):
	return s(h2 + r2 - 1) - s(h2 - 1) + s(h2 + r2)

def f2(h2, r2):
	return s(h2 + r2) - s(h2 - 1) + s(h2 + r2)
(n, h) = map(int, input().split())
if n <= s(h):
	for i in range(max(int(math.sqrt(2 * n)) - 10, 0), int(math.sqrt(2 * n)) + 10):
		if s(i) >= n:
			print(i)
			sys.exit(0)
l = -1
r = n
while r - l > 1:
	m = (l + r) // 2
	if f(h, m) < n:
		l = m
	else:
		r = m
ans1 = h + 2 * r
l = -1
r = n
while r - l > 1:
	m = (l + r) // 2
	if f2(h, m) < n:
		l = m
	else:
		r = m
ans2 = h + 2 * r + 1
print(min(ans1, ans2))


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

def chek(x):
	if x <= H:
		if (x + 1) * x // 2 >= n:
			return 1
		else:
			return 0
	h = 0
	h = h + (H + 1) * H // 2
	p = x - H
	h = h + p * H
	p += 1
	p -= 2
	if p > 0:
		if p % 2 == 1:
			xx = p // 2 + 1
			h = h + xx * xx
		else:
			xx = p // 2
			h = h + xx * (xx + 1)
	if h >= n:
		return 1
	return 0
l = 1
r = n
while l + 1 < r:
	m = (l + r) // 2
	if chek(m) == 1:
		r = m
	else:
		l = m
if chek(l) == 1:
	r = l
print(r)


def main():
	import sys
	input = sys.stdin.readline
	(N, H) = map(int, input().split())
	if H * (H + 1) // 2 >= N:
		ok = H
		ng = 0
		mid = (ok + ng) // 2
		while ok - ng > 1:
			if (mid + 1) * mid // 2 >= N:
				ok = mid
			else:
				ng = mid
			mid = (ok + ng) // 2
		print(ok)
		exit()
	ok = 10 ** 12
	ng = 0
	mid = (ok + ng) // 2
	while ok - ng > 1:
		if mid + H & 1:
			x = (H + mid - 1) // 2
			M = x * (x + 1) // 2 + (x + H) * (x - H + 1) // 2
		else:
			x = (H + mid) // 2
			M = x * (x + 1) // 2 + (x - 1 + H) * (x - H) // 2
		if M >= N:
			ok = mid
		else:
			ng = mid
		mid = (ok + ng) // 2
	print(ok)
main()


from math import ceil, sqrt
(n, H) = map(int, input().split(' '))
k = ceil(0.5 * (sqrt(8 * n + 1) - 1))
while k * k + k >= 2 * n:
	k -= 1
while k * k + k < 2 * n:
	k += 1
if k <= H:
	print(k)
else:
	k = ceil(sqrt(2 * H * H - 2 * H + 4 * n) - H)
	if (k - H) % 2 == 1:
		k += 1
	a = (k - H) // 2
	while (H + a) * (H + a + 1) + (H + a - 1) * (H + a) - (H - 1) * H >= 2 * n:
		k -= 2
		a -= 1
	while (H + a) * (H + a + 1) + (H + a - 1) * (H + a) - (H - 1) * H < 2 * n:
		k += 2
		a += 1
	m = k
	k = ceil(sqrt(2 * H * H - 2 * H + 4 * n + 1) - H - 1)
	if (k - H) % 2 == 0:
		k += 1
	a = (k - H - 1) // 2
	while (H + a) * (H + a + 1) + (H + a + 1) * (H + a) - (H - 1) * H >= 2 * n:
		k -= 2
		a -= 1
	while (H + a) * (H + a + 1) + (H + a + 1) * (H + a) - (H - 1) * H < 2 * n:
		k += 2
		a += 1
	print(max(min(m, k), H + 1))


def get(a):
	if a <= h:
		return a * (a + 1) // 2
	tmp = a - h + 1
	re = h * (h - 1) // 2
	l = (tmp + 1) // 2
	r = tmp // 2
	re += l * (h - 1 + l + h) // 2
	re += r * (h - 1 + r + h) // 2
	return re
lo = 1
hi = 1000000000000000001
(n, h) = list(map(int, input().split()))
while lo < hi:
	mi = (lo + hi) // 2
	if get(mi) < n:
		lo = mi + 1
	else:
		hi = mi
print(lo)


(n, h) = list(map(int, input().split()))
left = 1
right = n
mid = 0
while right > left:
	mid = (left + right) // 2
	maxnum = 0
	if mid <= h:
		maxnum = (1 + mid) * mid // 2
	else:
		maxnum = (mid + mid - h + 2) * (h - 1) // 2
		tmplen = mid - h + 1
		if tmplen % 2 == 0:
			high = tmplen // 2
			maxnum += (tmplen + 2) * high // 2
		else:
			high = (tmplen + 1) // 2
			maxnum += (tmplen + 1) * high // 2
	if maxnum >= n:
		right = mid
	else:
		left = mid + 1
print(right)


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

def fun(t, h):
	if t <= h:
		return (t * t + t) // 2
	if (t - h) % 2 == 1:
		ret = h + (t - h) // 2
		ans = (t - h) // 2 + 1
		return ans * (h + ret) // 2 + ret * (ret + 1) // 2
	ret = h + (t - h) // 2
	ans = (t - h) // 2 + 1
	return ans * (h + ret) // 2 + ret * (ret - 1) // 2
l = 1
r = 1000000000000000000
while l < r:
	m = (l + r) // 2
	if n > fun(m, h):
		l = m + 1
	else:
		r = m
print(l)


import math
(n, h) = map(int, input().split())

def isok(m):
	return m * (m + 1) // 2 <= n
l = 1
r = h
m = l
while l < r - 1:
	m = (l + r) // 2
	if isok(m):
		l = m
	else:
		r = m
h1 = 0
if isok(r):
	h1 = r
elif isok(m):
	h1 = m
else:
	h1 = l
h2 = math.floor((n + h1 * (h1 - 1) // 2) ** 0.5)
X = h2 ** 2 - h1 * (h1 - 1) // 2
i = 0
if (n - X) % h2 != 0:
	i = 1
print(2 * h2 - h1 + (n - X) // h2 + i)


(n, h) = list(map(int, input().split()))
a = 1
b = n
while 1:
	m = (a + b) // 2
	t1 = ((h + m - 1) * max(m - h, 0) + m * (m + 1)) // 2
	t2 = ((h + m) * max(m + 1 - h, 0) + (m + 1) * (m + 2)) // 2
	if t1 > n:
		b = m
	elif n < t2:
		l = max(m - h, 0) + m
		(l, t) = (l + (n - t1) // m, t1 + (n - t1) // m * m)
		if t < n:
			l += 1
		print(l)
		break
	else:
		a = m


def check(a):
	if a <= h:
		return (a + 1) * a // 2 >= n
	else:
		kol = a - h + 1
		kol1 = (a - h + 1) // 2
		kol2 = kol - kol1
		return (h - 1) * h // 2 + (h + kol1 - 1) * (h + kol1) // 2 - (h - 1) * h // 2 + (h + kol2 - 1) * (h + kol2) // 2 - (h - 1) * h // 2 >= n
(n, h) = map(int, input().split())
l = 0
r = n
while l + 1 < r:
	m = (l + r) // 2
	if check(m):
		r = m
	else:
		l = m
print(r)


def f(x):
	global h
	if x <= h:
		return x * (x + 1) // 2
	elif (x - h) % 2 == 0:
		return (x - h) ** 2 // 4 + h * (x - h) + h * (h + 1) // 2
	else:
		return (x - h + 1) ** 2 // 4 - (x - h + 1) // 2 + h * (x - h) + h * (h + 1) // 2
(n, h) = map(int, input().split())
l = 0
r = n
while 1 < r - l:
	m = (l + r) // 2
	if n <= f(m):
		r = m
	else:
		l = m
print(r)


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

def calc(mid):
	if mid <= h:
		return (1 + mid) * mid // 2
	peak = h - 1 + (mid - (h - 1) + 1) // 2
	if (mid - (h - 1)) % 2 == 0:
		return (h + peak) * (peak - h + 1) // 2 + (1 + peak) * peak // 2
	return (h + peak) * (peak - h + 1) // 2 + peak * (peak - 1) // 2
(l, r) = (0, n + 1)
while r - l > 1:
	mid = (l + r) // 2
	if calc(mid) < n:
		l = mid
	else:
		r = mid
print(r)


(n, H) = map(int, input().strip().split())

def c(x):
	if x > H:
		tmp = (H + x) * (x - H + 1) / 2 + x * (x - 1) / 2
	else:
		tmp = (1 + x) * x / 2
	if tmp <= n:
		return True
	else:
		return False
(l, r) = (0, n)
while l <= r:
	mid = int((l + r) / 2)
	if c(mid):
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
if ans > H:
	tmp = n * 2 - ((H + ans) * (ans - H + 1) + ans * (ans - 1))
	tmp = int(tmp / 2)
	if tmp > ans:
		print(ans * 2 - H + 2)
	elif tmp > 0:
		print(ans * 2 - H + 1)
	else:
		print(ans * 2 - H)
else:
	tmp = n * 2 - (1 + ans) * ans
	tmp = int(tmp / 2)
	if tmp > ans:
		print(ans + 2)
	elif tmp > 0:
		print(ans + 1)
	else:
		print(ans)


import sys
(n, H) = map(int, input().split())
(ok, ng) = (0, n + 1)
while abs(ok - ng) > 1:
	mid = ok + ng >> 1
	if mid * (mid + 1) >> 1 <= n:
		ok = mid
	else:
		ng = mid
if ok <= H:
	n -= ok * (ok + 1) >> 1
	print(ok + (1 if n else 0))
	exit()
(ok, ng) = (H, 10 ** 18)
while abs(ok - ng) > 1:
	mid = ok + ng >> 1
	m = mid * (mid + 1) - ((H - 1) * H >> 1) - mid
	if m <= n:
		ok = mid
	else:
		ng = mid
n -= ok * (ok + 1) - ((H - 1) * H >> 1) - ok
print(ok + (ok - H) + (n + ok - 1) // ok)


INF = 1000000000000000000

def f(k, n, h):
	h1 = min(k, h)
	a = k * k
	b = h1 * (h1 - 1) // 2
	c = a - b
	return c > n
(n, h) = map(int, input().split())
low = 1
high = INF
while low < high:
	mid = low + (high - low) // 2
	if f(mid, n, h) == True:
		high = mid
	else:
		low = mid + 1
k = low - 1
h1 = min(k, h)
spot = 2 * k - h1
requires = k * k - h1 * (h1 - 1) // 2
leftOver = n - requires
spot += (leftOver + k - 1) // k
print(spot)


def ok(val):
	x = val - h
	res = get(val) + (h + val - 1) * x // 2
	return res

def ok2(val):
	res = get(val) + (h + val) * (val - h + 1) // 2
	return res

def get(val):
	return (1 + val) * val // 2
line = input().split(' ')
n = line[0]
h = line[1]
n = int(n)
h = int(h)
ans = -1
if get(h) >= n:
	l = 1
	r = n
	while l <= r:
		mid = (l + r) // 2
		if get(mid) >= n:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	print(ans)
else:
	l = h
	r = 10 ** 12
	while l <= r:
		mid = (l + r) // 2
		if ok(mid) >= n:
			ans1 = mid
			r = mid - 1
		else:
			l = mid + 1
	ans1 = ans1 + ans1 - h
	l = h
	r = 10 ** 12
	ans2 = -1
	while l <= r:
		mid = (l + r) // 2
		if ok2(mid) >= n:
			ans2 = mid
			r = mid - 1
		else:
			l = mid + 1
	ans2 = ans2 + ans2 - h + 1
	if ans1 > ans2:
		print(ans2)
	else:
		print(ans1)


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

def g(n):
	if n % 2 == 0:
		return 2 * f(n // 2)
	else:
		return f(n // 2 + 1) + f(n // 2)
(n, h) = (int(x) for x in input().split(' '))
if f(h) >= n:
	(lo, hi) = (1, n)
	while lo < hi:
		mid = (lo + hi) // 2
		if f(mid) >= n:
			hi = mid
		else:
			lo = mid + 1
	print(hi)
else:
	h = h - 1
	n += f(h)
	(lo, hi) = (h, n)
	while lo < hi:
		mid = (lo + hi) // 2
		if g(mid) >= n:
			hi = mid
		else:
			lo = mid + 1
	print(hi - h)


def sumab(a, b):
	return (a + b) * (b - a + 1) // 2

def calc(spot, H):
	if spot <= H:
		return spot * (spot + 1) // 2
	if (H - spot) % 2 == 0:
		return sumab(1, H + (spot - H) // 2) + sumab(H, H + (spot - H) // 2 - 1)
	return sumab(1, H + (spot - H) // 2) + sumab(H, H + (spot - H) // 2 - 1) + H + (spot - H) // 2

def solve():
	(n, H) = map(int, input().split())
	if n == 1:
		print(1)
		return 0
	st = 1
	en = 10 ** 20
	while st < en:
		mid = (st + en) // 2
		if calc(mid, H) >= n:
			en = mid
		else:
			st = mid + 1
	print(st)
solve()


def check(n, t):
	su = t * (t + 1) // 2
	if n >= su:
		return 1
	else:
		return 0

def check2(n, ch, l):
	sua = (ch + l) * (l - ch + 1) // 2
	sub = l * (l - 1) // 2
	if sua + sub > n:
		return 0
	else:
		return 1
(n, h) = map(int, input().split())
l = 0
r = h
while r - l > 1:
	mid = (l + r) // 2
	if check(n, mid):
		l = mid
	else:
		r = mid
ch = 0
if check(n, r):
	ch = r
else:
	ch = l
l = ch
r = 10000000000
while r - l > 1:
	mid = (l + r) // 2
	if check2(n, ch, mid):
		l = mid
	else:
		r = mid
fans = 0
if check2(n, ch, r):
	fans = r
else:
	fans = l
ans = fans + fans - ch
sua = (ch + fans) * (fans - ch + 1) // 2
sub = fans * (fans - 1) // 2
ff = sua + sub
n = n - ff
ans += (n + fans - 1) // fans
print(ans)


def check(n, h, t):
	if t < h:
		return n <= t * (t + 1) // 2
	if n <= h * (h - 1) // 2:
		return True
	n -= h * (h - 1) // 2
	t -= h - 1
	if t % 2 == 0:
		upper = t // 2 * (t // 2 + 1)
		lower = (h - 1) * t
		return n <= upper + lower
	else:
		upper = (t // 2 + 1) * (t // 2 + 1)
		lower = (h - 1) * t
		return n <= upper + lower
(n, h) = map(int, input().split())
(lo, hi, ans) = (1, n - 1, n)
while lo <= hi:
	mid = lo + hi >> 1
	if check(n, h, mid):
		ans = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(ans)


import sys
readline = sys.stdin.readline

def check(x):
	if x <= H:
		if x * (x + 1) // 2 >= N:
			return True
		else:
			return False
	res = x - H - 1
	r1 = res // 2
	r2 = res - r1
	if (r1 * (r1 + 1) + r2 * (r2 + 1)) // 2 + (x - H) * H + H * (H + 1) // 2 >= N:
		return True
	else:
		return False
(N, H) = map(int, readline().split())
ok = N
ng = 0
while abs(ok - ng) > 1:
	med = (ok + ng) // 2
	if check(med):
		ok = med
	else:
		ng = med
print(ok)


import math

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

def getTransIntList(n):
	first = getIntList()
	m = len(first)
	result = [[0] * n for _ in range(m)]
	for i in range(m):
		result[i][0] = first[i]
	for j in range(1, n):
		curr = getIntList()
		for i in range(m):
			result[i][j] = curr[i]
	return result
(n, H) = getIntList()

def getLim(l):
	if l <= H:
		return l * (l + 1) // 2
	diff = l - H
	x = diff // 2
	if diff % 2 == 0:
		return l * (l + 1) // 2 - x * (x + 1)
	return l * (l + 1) // 2 - (x + 1) * (x + 1)

def solve(n):
	l = 1
	while getLim(l) < n:
		l *= 2
	upLim = l
	lowLim = l // 2
	diff = upLim - lowLim
	while upLim - lowLim > 1:
		curr = (upLim + lowLim) // 2
		if getLim(curr) >= n:
			upLim = curr
		else:
			lowLim = curr
	return upLim
print(solve(n))


import sys
[n, H] = map(int, sys.stdin.read().split())
INF = 1000000000000000000000000000000

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

def build(n, h):
	vol = tri(h)
	if h > H:
		r = h - H
		l = h - 1 - r
		sys.stderr.write('BUILD {} : {} {}\n'.format(h, l, r))
		sys.stderr.write('LSIDE: {}\n'.format(tri(l + r) - tri(l)))
		vol += tri(l + r) - tri(l)
		w = h + r
	else:
		w = h
	if vol > n:
		sys.stderr.write('BUILD {} -> NO WAY\n'.format(h))
		return INF
	n -= vol
	w += n // h
	if n % h > 0:
		w += 1
	sys.stderr.write('BUILD {} -> {}\n'.format(h, w))
	return w
l = 1
r = n
while l + 4 < r:
	sys.stderr.write('RANGE {}..{}\n'.format(l, r))
	a = (l + l + r + 2) // 3
	b = (l + r + r + 2) // 3
	ay = build(n, a)
	by = build(n, b)
	if by == INF:
		r = b
		continue
	if ay < by:
		r = b
	else:
		l = a
ans = INF
for i in range(l, r + 1):
	ans = min(ans, build(n, i))
print(ans)


import math
(n, H) = map(int, input().split())
cn = n

def f(top, H):
	k = top - H + 1
	off = 0
	if k % 2 == 1:
		off = k // 2
	k = k // 2
	return H * (H - 1) // 2 + (H * (top - H + 1) + k * (k - 1) + off)
if n >= (H - 1) * H // 2:
	n -= (H - 1) * H // 2
	ans = H - 1
	ans += (n + H - 1) // H
	l = H
	r = 10 ** 18
	while l < r:
		mid = (l + r) // 2
		if f(mid, H) < cn:
			l = mid + 1
		else:
			r = mid
	ans2 = l
	print(min(ans, ans2))
else:
	l = 1
	r = H
	while l < r:
		mid = (l + r) // 2
		if mid * (mid + 1) // 2 < n:
			l = mid + 1
		else:
			r = mid
	print(l)


(n, H) = map(int, input().split())
l = 1
r = n
while l < r:
	mid = int((l + r) / 2)
	ans = 0
	if mid <= H:
		ans = int(mid * (mid + 1) // 2)
		pass
	else:
		R = int(mid - (H - 1))
		Len = int(R - 2)
		ans = ans + int(H * (H - 1) // 2)
		tmp = int(R / 2)
		ans = ans + (H + H + tmp - 1) * tmp + (R - tmp * 2) * (H + tmp)
		pass
	if ans >= n:
		r = mid
	else:
		l = mid + 1
	pass
print('%d' % l)


import math
str = input('')
(n, H) = (int(str.split(' ')[0]), int(str.split(' ')[1]))
maxh = 0
if H + H * H >= 2 * n:
	maxh = int(math.sqrt(2 * n)) - 1
	while maxh * (maxh + 1) <= 2 * n:
		maxh += 1
	maxh -= 1
	if maxh * (maxh + 1) == 2 * n:
		ans = maxh
	else:
		ans = maxh + 1
else:
	n = int(n + H * (H - 1) / 2)
	maxh = int(math.sqrt(n))
	if maxh * maxh == n:
		ans = 2 * maxh - H
	elif n - maxh * maxh > maxh:
		ans = 2 * maxh - H + 2
	else:
		ans = 2 * maxh - H + 1
print(ans)


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

def struct_size(n):
	half_n = n // 2
	if n % 2 == 0:
		return 2 * tri(half_n)
	else:
		return tri(half_n) + tri(half_n + 1)
(n, h) = map(int, input().split())
(a, b, c) = (0, n, 0)
while a < b:
	c = (a + b) // 2
	h_min = min([h - 1, c // 2])
	if struct_size(c) - tri(h_min) < n:
		a = c + 1
	else:
		b = c
h_min = min([h - 1, a // 2])
result = a - h_min
print(result)


def binsearch():
	l = 0
	r = 10 ** 10
	while r - l > 1:
		m = (l + r) // 2
		if (m * m + m) // 2 <= n:
			l = m
		else:
			r = m
	return l

def solve(x):
	val = x * x + (h - h * h) // 2
	if val > n or x < 1:
		return 2 * 10 ** 18
	else:
		return 2 * x - h + (0 if n == val else (n - val - 1) // x + 1)
(n, h) = map(int, input().split())
if (h + h * h) / 2 > n:
	x = binsearch()
	val = (x * x + x) // 2
	if val == n:
		print(x)
	elif n - val <= x:
		print(x + 1)
	elif n - val <= 2 * x:
		print(x + 2)
	else:
		print(x + 3)
else:
	x = int((n + (h * h - h) // 2) ** 0.5)
	ans = 2 * 10 ** 18
	for c in range(x - 100, x + 1):
		ans = min(ans, solve(c))
	print(ans)


import math
vec = input().strip().split(' ')
n = int(vec[0])
H = int(vec[1])
s = int(math.sqrt(n * 2))
while True:
	if s * (s + 1) // 2 > n:
		break
	s = s + 1
s = s - 1
if s > H:
	s = H
delta = s * (s + 1) // 2
diff = n - delta
count = s
xa = 1
xb = 2 * s
xc = -diff
d = xb * xb - 4 * xa * xc
k = -xb + math.sqrt(d)
k = math.floor(k / 2)
diff = diff - k * k - xb * k
s = s + k
count = count + 2 * k
if 0 < diff <= s:
	count = count + 1
	diff = 0
elif diff == 0:
	count = count
else:
	diff = 0
	count = count + 2
print(count)


def func1(number, number2):
	if number > 1414213569:
		return 1000000000000000099
	return (number + 1) * number // 2

def func2(number, number2):
	if number > 1414213569:
		return 1000000000000000099
	return (number - number2) * (number + number2 - 1) // 2 + number * (number + 1) // 2

def solve(first, last, number, number2, func):
	mid = (last + first) // 2
	number3 = func(mid, number2)
	while last >= first:
		if number3 < number:
			first = mid + 1
		elif number3 > number:
			last = mid - 1
		else:
			return mid
		mid = (last + first) // 2
		number3 = func(mid, number2)
	number3 = func(first, number2)
	if number3 == number:
		return first
	return last
(n, h) = map(int, input().split())
number = min(solve(2, 2000000001, n, 0, func1), h)
number2 = solve(2, 2000000001, n, number, func2)
number3 = (n - func2(number2, number)) / float(number2)
if number3 > int(number3):
	print(number2 - number + number2 + int(number3) + 1)
else:
	print(number2 - number + number2 + int(number3))


def main():
	(n, h) = map(int, input().split())
	l = -1
	r = 10 ** 18
	while r - l != 1:
		m = (r + l) // 2
		t = m + h - 1
		if m > h:
			if t % 2 == 1:
				j = t // 2 + 1 - h + 1
				s = j * (j + 1) // 2 + j * (h - 1) + (m - j) * (m - j + 1) // 2
				if s >= n:
					r = m
				else:
					l = m
			else:
				j = t // 2 - h + 1
				s = j * (j + 1) // 2 + j * (h - 1) + (m - j) * (m - j + 1) // 2
				if s >= n:
					r = m
				else:
					l = m
		else:
			s = m * (m + 1) // 2
			if s >= n:
				r = m
			else:
				l = m
	print(r)
main()


numbers = list(map(int, input().split()))
n = numbers[0]
H = numbers[1]
l = 0
r = n
while l + 1 < r:
	mid = (l + r) // 2
	if mid <= H:
		if mid * (mid + 1) >= n * 2:
			r = mid
		else:
			l = mid
		continue
	x = (mid + H) // 2
	pos = mid - x + 1
	val = (H + x - 1) * (pos - 1) // 2 + x * (x + 1) // 2
	if x - H + 1 < pos:
		val = (H + x) * (pos - 1) // 2 + x * (x + 1) // 2
	if val >= n:
		r = mid
	else:
		l = mid
print(r)


def f():
	if x <= m:
		return x * (x + 1) // 2
	t = x + m
	return t // 2 * (t - t // 2) - m * (m - 1) // 2
(n, m) = map(int, input().split())
(lo, hi) = (0, n)
while lo + 1 < hi:
	x = (lo + hi) // 2
	if f() < n:
		lo = x
	else:
		hi = x
print(hi)


def bst(n):
	l = 0
	r = 10 ** 44
	o = 0
	if n <= 0:
		return 0
	while l <= r:
		m = (l + r) // 2
		if m * (m + 1) // 2 >= n:
			o = m
			r = m - 1
		else:
			l = m + 1
	return o

def asc(x0, m):
	return x0 * m + m * (m - 1) // 2

def fitt(m, h):
	if m <= h:
		return m * (m + 1) // 2
	y = (m + h) // 2
	x = (m - h) // 2 + 1
	return asc(h, x) + asc(1, m - x)

def resi():
	(n, h) = map(int, input().split())
	t = bst(n)
	if t <= h:
		return t
	l = 0
	r = 10 ** 44
	sol = r
	while l <= r:
		m = (l + r) // 2
		if fitt(m, h) >= n:
			sol = m
			r = m - 1
		else:
			l = m + 1
	return sol
print(resi())


import math
(n, h) = map(int, input().split())
temp = h * (h - 1) // 2
if n <= temp:
	temp = int(math.sqrt(2 * n))
	temp1 = temp * (temp + 1) // 2
	if temp1 > n:
		temp -= 1
	temp1 = temp * (temp + 1) // 2
	n -= temp1
	ans = temp
	if n % temp != 0:
		ans += 1
	print(ans)
else:
	ans = h - 1
	temp = n + h * (h - 1) // 2
	temp = int(math.sqrt(temp))
	n -= h * (h - 1) // 2
	temp1 = temp * (temp + 1) - h * (h - 1)
	if temp1 > n:
		temp -= 1
	temp1 = temp * (temp + 1) - h * (h - 1)
	ans += 2 * (temp - h + 1)
	n -= temp1
	temp += 1
	if n == 0:
		print(ans)
	elif n <= temp:
		print(ans + 1)
	else:
		print(ans + 2)


(n, h) = map(int, input().split())
left = 0
right = 10 ** 18
while left + 1 != right:
	mid = (left + right) // 2
	if (mid + min(mid, h)) % 2 == 0:
		ans = (mid + min(h, mid)) // 2 * ((mid + min(mid, h)) // 2) - min(mid, h) * (min(mid, h) - 1) // 2
		if ans >= n:
			right = mid
		else:
			left = mid
	else:
		ans = ((mid + min(mid, h)) // 2 + 1) * ((mid + min(mid, h)) // 2) - min(mid, h) * (min(mid, h) - 1) // 2
		if ans >= n:
			right = mid
		else:
			left = mid
print(right)


(n, H) = [int(i) for i in input().split()]
start = 0
end = n
while start != end - 1:
	mid = (start + end) // 2
	h = min(H, mid)
	result = mid ** 2 - h * (h - 1) // 2
	if result <= n:
		start = mid
	else:
		end = mid
ans = 0
if H >= start:
	l1 = start
	first = start * (start + 1) // 2
	tomake = n - first
	if start != 0:
		add1 = tomake // start
	else:
		add1 = tomake
	if start != 0:
		if tomake % start != 0:
			add1 += 1
	print(l1 + add1)
else:
	l1 = start + (start - H)
	first = start * (start + 1) // 2
	second = (H + start - 1) * (start - H) // 2
	full = first + second
	tomake = n - full
	add1 = tomake // start
	if tomake % start != 0:
		add1 += 1
	print(l1 + add1)


import math
(n, H) = map(int, input().split())
x = (1 + H) * H // 2
if n == x:
	print(H)
elif n < x:
	H = int(math.sqrt(n * 2))
	if (H + 1) * H // 2 > n:
		H = H - 1
	ans = H
	x = (H + 1) * H // 2
	ans += (n - x + H - 1) // H
	print(ans)
else:
	x = (1 + H) * H // 2 + H
	ma = int(math.sqrt(n - x + H + H * H))
	tol = x + (ma + H + 1) * (ma - H) - ma
	if tol > n:
		ma = ma - 1
		tol = x + (ma + H + 1) * (ma - H) - ma
	ans = ma * 2 - H
	if n > tol:
		ans += (n - tol + ma - 1) // ma
	print(ans)


def f(k, n, h):
	if k <= h:
		return k * (k + 1) // 2 >= n
	m = (h + k) // 2
	return 2 * m * (m + 1) // 2 - (h - 1) * h // 2 - m * (2 * m - k == h) >= n
s = input().split()
n = int(s[0])
h = int(s[1])
b = 1
e = n
while b < e:
	m = (b + e) // 2
	if f(m, n, h):
		e = m
	else:
		b = m + 1
print(b)


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

def f(m):
	return ((h + m - 1) * max(m - h, 0) + m * (m + 1)) // 2
(a, b) = (1, n)
while 1:
	m = (a + b) // 2
	t = f(m)
	if t > n:
		b = m
	elif f(m + 1) <= n:
		a = m
	else:
		break
l = max(m - h, 0) + m
(l, t) = (l + (n - t) // m, t + (n - t) // m * m)
if t < n:
	l += 1
print(l)


def getSum1(x):
	return (x + 1) * x // 2

def getSum(l, r):
	return getSum1(r) - getSum1(l - 1)
(n, h) = map(int, input().split())
l = 1
r = n
while l != r:
	m = l + r + 1 >> 1
	cnt = 0
	if m > h:
		cnt += getSum(h, m - 1)
	cnt += getSum1(m)
	if cnt > n:
		r = m - 1
	else:
		l = m
cnt = 0
ans = 0
if l > h:
	cnt += getSum(h, l - 1)
	ans += l - h
cnt += getSum1(l)
ans += l
n -= cnt
ans += n // l
if n % l != 0:
	ans += 1
print(ans)


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

def p(k):
	return k * (k + 1) // 2

def pp(k):
	x = 0
	if k >= 2:
		x = k * (k - 1) // 2
	return int(x + h * k + (h + k) * (h + k + 1) // 2)
temp = h * (h + 1) // 2
c = 0
if n - temp >= 0:
	lb = 0
	ub = 100000000000000000000
	while lb < ub:
		mid = (lb + ub + 1) // 2
		if n < pp(mid):
			ub = mid - 1
		else:
			lb = mid
	sk = pp(lb)
	k = lb
	if sk == n:
		print(h + 2 * k)
	elif n <= sk + k + h:
		print(h + 2 * k + 1)
	else:
		print(h + 2 * k + 2)
else:
	lb = 1
	ub = h
	while lb < ub:
		mid = (lb + ub + 1) // 2
		if p(mid) <= n:
			lb = mid
		else:
			ub = mid - 1
	if p(lb) == n:
		print(lb)
	else:
		print(lb + 1)


(n, h) = map(int, input().split())
base = h * (h + 1) // 2
if n <= base:
	lo = 0
	hi = h + 1
	while lo < hi:
		mi = (lo + hi) // 2
		if mi * (mi + 1) // 2 >= n:
			hi = mi
		else:
			lo = mi + 1
	print(lo)
else:
	lo = 1
	hi = 10 ** 20

	def get(x):
		res = 0
		res += base
		res += x * h
		y = x - 1
		top = (y + 1) // 2
		if y % 2 == 1:
			res += top * (top - 1)
			res += top
		else:
			res += top * (top + 1)
		return res
	while lo < hi:
		mi = (lo + hi) // 2
		if get(mi) >= n:
			hi = mi
		else:
			lo = mi + 1
	print(lo + h)


def UpperDiv(a, b):
	if a < 0:
		return 0
	if a % b == 0:
		return a // b
	return a // b + 1

def GetAnswer(n, h, k):
	h1 = min(h, k)
	x = 2 * k - 1 - (h1 - 1)
	y = k * k - h1 * (h1 - 1) // 2
	return x + UpperDiv(n - y, k)

def Check(n, h, k):
	h1 = min(h, k)
	a = k * k
	b = h1 * (h1 - 1) // 2
	value = a - b
	return value <= n

def BinarySearch(n, h):
	left = 1
	right = n
	while right - left > 1:
		middle = (left + right) // 2
		if Check(n, h, middle):
			left = middle
		else:
			right = middle
	return left
(n, h) = map(int, input().split())
k = BinarySearch(n, h)
print(GetAnswer(n, h, k))


import sys
(n, H) = map(int, sys.stdin.readline().split())

def maximum_quantity(k):
	if k >= H:
		c = (k - H) // 2
		return H * (c + 1) + c * (c + 1) // 2 + (k - c) * (k - c - 1) // 2
	else:
		return k * (k + 1) // 2
k_inf = 0
k_sup = n
while k_sup - k_inf > 1:
	k = (k_inf + k_sup) // 2
	if maximum_quantity(k) >= n:
		k_sup = k
	else:
		k_inf = k
print(k_sup)


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

def f(x):
	if x <= H:
		return x * (x + 1) // 2
	if (x + H) % 2 == 0:
		M = (x + H) // 2
		return M * M - H * (H - 1) // 2
	else:
		M = (x + H - 1) // 2
		return M * (M + 1) - H * (H - 1) // 2
(lo, hi) = (-1, n + 1)
while hi - lo > 1:
	mid = (lo + hi) // 2
	if f(mid) >= n:
		hi = mid
	else:
		lo = mid
print(hi)


def ok(x, n, h):
	if x == 1:
		return n == 1
	if x == 2:
		return h >= 2 and n <= 3 or (h == 1 and n <= 2)
	ubound = 0
	if x <= h:
		ubound = x * (x + 1) // 2
	elif x == h + 1:
		ubound = h + (x - 1) * (h + 1) // 2
	else:
		exc = x - h
		if exc % 2 == 1 and x % 2 == 0:
			exc += 1
		coll = exc // 2 + 1
		if coll % 2 == 0 or h % 2 == 1:
			ubound = (coll - 1) * (h + h + coll - 2) // 2 + (x - (coll - 1)) * (h + coll - 1 + 1) // 2
		else:
			ubound = coll * (h + h + coll - 1) // 2 + (x - coll) * (h + coll - 1 + 1) // 2
	return ubound >= n
(n, h) = [int(x) for x in input().split(' ')]
a = n
b = 1 << 61
while b >= 1:
	if a - b >= 1 and ok(a - b, n, h):
		a -= b
	b = b // 2
print(a)


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

def sum(n):
	if not n:
		return 0
	return n * (n + 1) // 2

def can(len, max):
	height = len - max + 1
	return height - max + 1 <= h

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

def sq(len, max):
	height = len - max + 1
	res = sum(height) + (max - 1) * height
	if height > h:
		res -= sum(height - h)
	return res

def good(len):
	if len == 1:
		return n == 1
	l = 1
	r = len
	while l < r:
		m = (l + r) // 2
		if can(len, m):
			r = m
		else:
			l = m + 1
	return sq(len, l) >= n
l = 1
r = n
while l < r:
	m = (l + r) // 2
	if good(m):
		r = m
	else:
		l = m + 1
print(l)


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

def check(x):
	k = min(x, h)
	return x * x - (k * (k - 1) >> 1) >= n

def get(x):
	global n
	k = min(x, h)
	q = x * x - (k * (k - 1) >> 1)
	rest = 2 * x - k
	n -= q
	return rest + (n + x - 1) // x
(l, r) = (0, int(1e+18))
while r - l > 1:
	m = l + r >> 1
	if check(m):
		r = m
	else:
		l = m
print(get(r))


def f(N, H, n):
	total = 0
	if n <= H:
		total = n * (n + 1) // 2
	else:
		total = H * (H + 1) // 2
		n -= H
		n -= 1
		total += H
		(q, r) = (n // 2, n % 2)
		total += (q * (q + 1) // 2 + q * H) * 2
		total += r * (H + q + 1)
	return total >= N
(n, H) = map(int, input().split())
l = 0
r = n
while l < r:
	m = (l + r) // 2
	if f(n, H, m):
		r = m
	else:
		l = m + 1
print(r)


(n, h) = map(int, input().split())
d = h * (h + 1) // 2
if n >= d:
	ok = h
	ng = 10 ** 20
	while ng - ok > 1:
		mid = (ok + ng) // 2
		if (h + mid) * (mid - h + 1) // 2 + mid * (mid - 1) // 2 <= n:
			ok = mid
		else:
			ng = mid
	s = (h + ok) * (ok - h + 1) // 2 + ok * (ok - 1) // 2
	print(ok + ok - h + (n - s + ok - 1) // ok)
else:
	ok = 10 ** 20
	ng = 0
	while ok - ng > 1:
		mid = (ok + ng) // 2
		if mid * (mid + 1) // 2 >= n:
			ok = mid
		else:
			ng = mid
	print(ok)


(n, H) = map(int, input().split())
if H * (H + 1) // 2 >= n:
	(l, r) = (0, 10 ** 18)
	while r - l > 1:
		mid = r + l >> 1
		if mid * (mid + 1) // 2 >= n:
			r = mid
		else:
			l = mid
	print(r)
else:
	n += H * (H - 1) // 2
	(l, r) = (0, 10 ** 18)
	calc = lambda x: (x + 1) // 2 * (x // 2 + 1)
	while r - l > 1:
		mid = r + l >> 1
		if calc(mid) >= n:
			r = mid
		else:
			l = mid
	print(-H + 1 + r)


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

def f(len, H):
	if len <= H:
		return len * (len + 1) // 2
	if (len - H) % 2 == 1:
		x = H + (len - H) // 2
		c = (len - H) // 2 + 1
		return c * (H + x) // 2 + x * (x + 1) // 2
	x = H + (len - H) // 2
	c = (len - H) // 2 + 1
	return c * (H + x) // 2 + x * (x - 1) // 2
(lo, hi) = (1, 1000000000000000000)
while lo < hi:
	mid = (lo + hi) // 2
	if n > f(mid, H):
		lo = mid + 1
	else:
		hi = mid
print(lo)


n = 0
H = 0

def test(k):
	if k <= H:
		return (k + 1) * k // 2 >= n
	else:
		a = H * (2 * k + 1 - H) // 2
		cnt = (k - H - 1 + 1) // 2
		if (k - H - 1) % 2 == 0:
			start = 2
		else:
			start = 1
		b = (start + (k - H - 1)) * cnt // 2
		return a + b >= n
(n, H) = (int(x) for x in input().split())
lo = 1
hi = n
while lo < hi:
	mid = (lo + hi) // 2
	if test(mid):
		hi = mid
	else:
		lo = mid + 1
print(lo)


from math import sqrt, ceil

def get_range(piles, limit):
	min = piles
	max = piles * (piles + 1) // 2
	if piles > limit:
		overflow = piles - limit
		if overflow % 2 == 1:
			max -= (overflow // 2 + 1) ** 2
		else:
			max -= overflow // 2 * (overflow // 2 + 1)
	return (min, max)

def main():
	(n, h) = map(int, input().strip().split())
	if n == 1:
		print(1)
		return
	(l, r) = (0, n)
	while l != r:
		mid = int((l + r) // 2)
		(min, max) = get_range(mid, h)
		if min <= n <= max:
			r = mid
		else:
			l = mid + 1
	print(r)
main()


import math
(N, H) = input().split(' ')
N = int(N)
H = int(H)
H -= 1
if H * (H + 1) // 2 > N:
	res = int(math.floor(0.5 * (math.sqrt(8 * N + 1) - 1)))
	if res * (res + 1) // 2 == N:
		print(res)
	else:
		print(res + 1)
else:
	res = int(math.floor(0.5 * (math.sqrt(2 * H ** 2 + 2 * H + 4 * N + 1) - 2 * H - 1)))
	sm = (H + res) * (H + res + 1) - H * (H + 1) // 2
	if N == sm:
		print(2 * res + H)
	elif N - sm > H + res + 1:
		print(2 * res + H + 2)
	else:
		print(2 * res + H + 1)


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

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

def li():
	return list(mi())
(N, H) = mi()
tar = N + H * (H - 1) // 2
(lo, hi) = (H, tar)
while lo < hi:
	mid = (lo + hi + 1) // 2
	if mid * mid <= tar:
		lo = mid
	else:
		hi = mid - 1
if lo * lo == tar:
	ans = 2 * lo - H
elif lo * lo > tar:
	(lo1, hi1) = (1, N)
	while lo1 < hi1:
		mid1 = (lo1 + hi1 + 1) // 2
		if mid1 * (mid1 + 1) // 2 <= N:
			lo1 = mid1
		else:
			hi1 = mid1 - 1
	ans = lo1
	if lo1 * (lo1 + 1) // 2 < N:
		ans += 1
else:
	dif = tar - lo * lo
	if dif <= lo:
		ans = 2 * lo - H + 1
	else:
		ans = 2 * lo - H + 2
print(ans)


import math
(n, h) = (int(i) for i in input().split())
l = 0
r = n + 1
for i in range(200):
	m = (l + r) // 2
	if m * m + m - 2 * n <= 0:
		l = m
	else:
		r = m
if m * m + m - 2 * n <= 0 and (m + 1) * (m + 2) - 2 * n > 0:
	m = m
elif (m + 1) * (m + 2) - 2 * n <= 0 and (m + 2) * (m + 3) - 2 * n > 0:
	m = m + 1
else:
	m = m - 1
t = (m * m + m) // 2
t = n - t
if m <= h:
	if t > 0:
		print(m + 1)
		exit()
	else:
		print(m)
		exit()
n = n + h * (h - 1) // 2
l = 0
r = n + 1
for i in range(200):
	m = (l + r) // 2
	if m * m - n <= 0:
		l = m
	else:
		r = m
if m * m - n <= 0 and (m + 1) * (m + 1) - n > 0:
	m = m
elif (m + 1) * (m + 1) - n <= 0 and (m + 2) * (m + 2) - n > 0:
	m = m + 1
else:
	m = m - 1
r = m * m
r = n - r
print(2 * m - h + (r + m - 1) // m)


(n, h) = map(int, input().split())
(l, r) = (0, n)
while l + 1 < r:
	p = (l + r) // 2
	if p * (p + 1) // 2 >= n:
		(needToRemove, canRemove) = (p - h, p * (p + 1) // 2 - n)
		needToRemove = max(needToRemove, 0)
		d = needToRemove // 2
		canRemove -= d * (d + 1)
		if needToRemove % 2:
			canRemove -= needToRemove // 2 + 1
		if canRemove >= 0:
			r = p
		else:
			l = p
	else:
		l = p
print(r)