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: interview

Starter code:

Solutions:
n, k = list(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 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)


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)
	else:
		if 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)

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 = list(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)


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)

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)


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)

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
	#print("%d, %d" % (lo, hi))
	if n > f(mid, H): lo = mid + 1
	else: hi = mid
print(lo)

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
# binary search
l = 1
r = 1000000000000000000
while l < r:
	m = (l + r) // 2
	if n > fun(m, h): 
		l = m + 1
	else: 
		r = m
print(l)

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 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()


n,h = list(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;


#for i in range(0,20):
    #print (i, g(i))

a = 0
b = 10**20

while (a!=b):
    #print(a,b);
    c = (a+b)//2
    if (n <= g(c)):
        b = c
    else:
        a = c+1

print(a)



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 = list(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)


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)

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))

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();
#l*(l+1)/2=n
#l**2+l-2n=0;
#l=-1+sqrt(1+8n)/2
#if l>H
#l*(l+1)/2-k
#k=l-H+l-H-2+...
#g(x)= x+ x-2+ x-4...
#g(2*x)=x*(x+1);
#g(2*x+1)=x+1+x*(x+1);
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:
        #print(l, getLim(l))
        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))

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)
	return
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(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 = list(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)


#!/bin/python3
import sys

[n, H] = list(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)


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)

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)



n, H = input().split()

n = int(n)
H = int(H)

def can(m):
    nonlocal 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)


#!/usr/bin/env python3

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

# first True
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)


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()