def v(length, start):
    W = start * (start + 1) // 2
    t = max(0, start - length)
    T = t * (t + 1) // 2
    return W - T + max(0, length - start)

def check(p):
    return p + v(k - 1, p - 1) + v(n - k, p - 1) <= m

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

from sys import stdin, stdout

n, m, k = map(int, stdin.readline().split())

left = k - 1
right = n - k
l = 1
r = m + 1

while r - l > 1:
    mid = (r + l) // 2
    cnt = mid

    if mid > left:
        cnt += (2 * mid - 1 - left) * left // 2
    else:
        cnt += mid * (mid - 1) // 2 + left - (mid - 1)

    if mid > right:
        cnt += (2 * mid - 1 - right) * right // 2
    else:
        cnt += mid * (mid - 1) // 2 + right - (mid - 1)

    if cnt <= m:
        l = mid
    else:
        r = mid

stdout.write(str(l))

n, m, k = map(int, input().split())
m -= n
def Sum(cnt, x):
    return cnt * (x - 1 + (x - cnt)) // 2
def check(x):
    l = min(k - 1, (x - 1))
    r = min(n - k, (x - 1))
    cur = Sum(l, x) + Sum(r, x) + x
    return cur <= m
L = -1
R = 10 ** 20
while R - L > 1:
    M = (L + R) >> 1
    if check(M): L = M
    else: R = M
print(L + 1)

# n=int(input())
#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))
# n,k=map(int,input().split())
# arr=list(map(int,input().split()))
#ls=list(map(int,input().split()))
#for i in range(m):
# cnt += (extra + k - 1) // k
# n=int(input())
#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))
# n,k=map(int,input().split())
# arr=list(map(int,input().split()))
#ls=list(map(int,input().split()))
#for i in range(m):
#from sys import stdin
#n=int(stdin.readline())
#for _ in range(int(input())):
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

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

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

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

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
def can(x):
    fr=k-1
    ba=n-k
    total=x
    if fr>0:
        if x>fr:
            total+=(x-fr)*fr+(fr-1)*fr//2
        else:
            total+=(x-1) * x // 2
            total+=fr-(x-1)
    if ba>0:
        if x > ba :
            total+=(x-ba)*ba+(ba-1)*ba//2
        else:
            total+=(x-1)*x//2
            total+=(ba-(x-1))
    #print(total)
    if total<=m:
        return True
    else:
        return False
n,m,k= map(int, input().split())
low=1
high=m-n+1
ans=-1
while low<=high:
    mid=(low+high)//2
    #print("mid",mid)
    if can(mid):
        ans=mid
        low=mid+1
    else:
        high=mid-1
print(ans)

R = lambda: map(int, input().split())
n, p, k = R()
l, r = 1, p
while l < r:
    m = (l + r + 1) // 2
    cl = (m + max(1, m - k + 1)) * min(k, m) // 2 + max(k - m, 0)
    cr = (m + max(1, m - (n - k))) * min(n - k + 1, m) // 2 + max(n - k + 1 - m, 0)
    if cl + cr - m <= p:
        l = m
    else:
        r = m - 1
print(l)

def read(type=int):
    return type(input())

def read_arr(type=int):
    return [type(token) for token in input().split()]

def runB():
    n, m, k = read_arr()
    ans = 1
    m -= n
    l, r = k, k
    # print(ans, m)
    while (r < n or l > 1) and m > 0:
        ans += 1
        m -= (r - l + 1)
        if l > 1:
            l -= 1
        if r < n:
            r += 1
        # print(ans, m)
    ans += (m // n)
    print(ans)

runB()

n, m, k = tuple(int(_) for _ in input().split())

extra_pillows = m - n
max_pillow = 1

if n == 1:
    print(m)
elif n == 2:
    if m % 2 == 0:
        print(int(m / 2))
    else:
        print(int(m / 2) + 1)
else:
    for i in range(extra_pillows):
        step_pillows = 1 + min(k - 1, i) + min(n - k, i)
        if extra_pillows >= step_pillows:
            extra_pillows -= step_pillows
            max_pillow += 1
        else:
            break

    print(max_pillow)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     if left < 1 and right > hobs:
          pilCount+=pillows//hobs
          break
     elif left < 1:
          pillows-=(right)
     elif right > hobs:
          pillows-=(hobs-left+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

# from itertools import combinations
# from bisect import bisect_right
# from functools import *
# from collections import Counter

I = lambda: list(map(int, input().split()))
n, m, k = I()
l, r = 1, m + 1
onLeft, onRight = k - 1, n - k
while l < r - 1:
    amount = (l + r) >> 1
    s = amount
    for neighbors in [onLeft, onRight]:
        if neighbors > amount - 1:
            s += (amount - 1) * amount // 2 + neighbors - amount + 1
        else:
            s += (amount - neighbors + amount - 1) * neighbors // 2
    if s <= m:
        l = amount
    else:
        r = amount
print(l)

q,w,e=map(int,input().split())
w-=q
z=e-1
x=q-e
z,x=min(z,x),max(z,x)
ans=1
t=1
while (w-t)>=0:
    w-=t
    ans+=1
    if z==x==0:
        ans+=w//t
        break
    if z>0:
        z-=1
        t+=1
    if x>0:
        x-=1
        t+=1
print(ans)

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

def Sum(cnt, x):
    return cnt * (x - 1 + (x - cnt )) // 2
def check(x):
    l = min(k - 1, (x - 1))
    r = min(n - k, (x - 1))
    cur = Sum(l, x) + Sum(r, x) + x
    return cur<= m
L = -1
R = 10 ** 20
while R - L > 1:
    M = ( L + R) >> 1
    if check(M): L = M
    else: R = M
print(L + 1)

def v(ln, mx):
    return mx * (mx + 1) // 2 - (0 if ln > mx else (mx - ln) * (mx - ln + 1) // 2) + max(0, ln - mx)

def ok(n, m, k, val):
    return val + v(k - 1, val - 1) + v(n - k, val - 1) <= m

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

def pil_add(height, div):
    add = height
    if height > div:
        add = div
    return add

hobb, pillow, number = (int(i) for i in input().split())

div_first = number
div_last = hobb - number + 1

other_pillow = pillow - hobb

height = 0
heap_pil = 0

right_flag = False
left_flag = False

while heap_pil <= other_pillow:
    height += 1
    if not (right_flag and left_flag):

        right = pil_add(height, div_first)
        if right == div_first:
            right_flag = True

        left = pil_add(height, div_last)
        if left == div_last:
            left_flag = True

        heap_pil += right + left - 1
    else:
        other_pillow -= heap_pil
        height += int(other_pillow / hobb)
        break

print(height)

#@author:LENOVO | 25-Jan-2017 | 11:37:20 PM
import sys
n,m,k=map(int,input().split())
ans=1
m-=n
l=min(k-1,n-k)
step=1
for i in range(l):
    if m-step<0:
        print(ans)
        sys.exit(0)
    m-=step
    step+=2
    ans+=1
while step<n:
    if m-step<0:
        print(ans)
        sys.exit(0)
    m-=step
    step+=1
    ans+=1
ans+=m//n
print(ans)

__author__ = 'zihaozhu'
from sys import stdin

def summation(a,b):
    if a>b:
        return summation(b,a)
    return (b + a) * (b - a + 1)/2

hobbits, pillow, frodo = map(int,stdin.readline().split())

lo = 1
hi = pillow

maxpossible = pillow-hobbits

while lo<hi:
    mid = (lo+hi)//2
    left = max(0, mid - frodo + 1)
    right = max(0, mid - (hobbits-frodo))
    if summation(left,mid) + summation(right,mid) -  mid > maxpossible:
        hi = mid
    else:
        lo = mid +1

print(lo)

"""
if maxpossible<=2:
    print(maxpossible)
elif hobbits == frodo and maxpossible-1<2:
    print(pillow)
elif frodo == 1 and maxpossible-1<2:
    print(pillow)

else:

if hobbits == 1 and frodo==hobbits:
    print(pillow)
elif frodo!=1 and frodo!=hobbits:
    n = 0
    # 4 7 2
    # 3
    #4 9 2
    #2 3 2 2

    while (n*(n+1)/2) + (n*(n+1)/2) < maxpossible:
        n+=1
    if (n*(n+1)/2)+(n*(n+1)/2)>maxpossible:
        n-=1
    print(n)
    if (n*(n+1)/2)+(n*(n+1)/2)+(n+1)<pillow:
        print(int(n+1+(((n*(n+1)/2)+(n*(n+1)/2)+(n+1))/hobbits)))
        #print (int(n+1+pillow-(n*(n+1)/2)-(n+1)-(n*(n+1)/2)))
    else:
        print(n+1)
else:
    n=0
    # 3 6 1
    # 3
    # 3 10 3
    # 7
    while (n*(n+1)/2)<maxpossible:
        n+=1
    if (n*(n+1)/2) > maxpossible:
        n-=1
    if (n*(n+1)/2)+(n+1)<pillow:
        print (int(n+1+pillow-(n*(n+1)/2)-(n+1)))
    else:
        print(n+1)
"""

# -*- coding: utf-8 -*-
"""
Created on Wed Apr  3 10:37:54 2019

@author: slappy
"""

def _sum_n(n):
    return int((n * (n + 1)) // 2)
def _sum(p, k):
    return _sum_n(p) - (_sum_n(p - k) if p > k else p - k)
def _solve():
    n, m, k = map(int, input().split())
    low, high = 1, 2e9
    while low <= high:
        mid = int((low + high) // 2)
        sum = int(_sum(mid, k) + _sum(mid - 1, n - k))
        #print (mid, ' ', sum)
        if sum <= m:
            ans = mid
            low = mid + 1
        else:
            high = mid - 1
    return ans
print (int(_solve()))

# -*- coding: utf-8 -*-
"""
Created on Thu Jan 26 22:18:23 2017

@author: USER PC
"""

n,m,k=input().split(" ")
n,m,k=int(n),int(m),int(k)
ans=1
m-=n
a=0
b=0
c=a+b+1
while m>=c:
    ans+=1
    m-=c
    if(a<k-1): a+=1
    if(b<n-k): b+=1
    if(a==k-1 and b==n-k): break
    c=a+b+1
ans+=m//n
print(ans)

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

m -= n
d = 0
k -= 1
out = 1
while m > 1 and d != max(k, n - k - 1):
    out += 1
    m -= 1
    left = min(d, k)
    right = min(d, n - k - 1)
    d += 1
    m -= left
    m -= right
out += m // n

print(out)

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

def valid(x):
    a = min(k - 1, x - 1)
    b = min(n - k, x - 1)
    s1 = a * (x - 1 + x - a) // 2
    s2 = b * (x - 1 + x - b) // 2
    return s1 + s2 + x <= m

l, r = 0, (1<<62)
while r > l+1:
    mid = l + r >> 1
    if valid(mid):
        l = mid
    else:
        r = mid
print(l+1)

n,m,k=map(int,input().split())
m-=n
f=1
l=k-1
r=n-k
p=1
while m>=p:
    f+=1
    m-=p
    p+= (l>0)+(r>0)
    if l: l-=1
    if r: r-=1
    if l==r==0:
        f+=(m//p)
        break
print(f)

n,m,k= map(int,input().split())
def calc(x,n,k):
    k-=1
    r = n - k;
    k = min(k,x-1)
    r = min(r,x)
    return ((2*x - k -1)*k//2) + (((2*x - r + 1)*(r))//2)
def bsearch(l, r):
    if l > r:
        return r
    mid = (l + r) //2
    if calc(mid,n,k) <= m:
        return bsearch(mid + 1,r)
    return bsearch(l, mid - 1)
frod = 1;
m -= n
frod += bsearch(0,1000000001)
print(frod)

n,m,k=map(int,input().split())
m-=n
l,u,x=k,k,1
while m>0 and (u<n or l>1):
    x+=1
    m-=(u-l+1)
    if l>1: l-=1
    if u<n: u+=1
print(x+(m//n))

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y1 = (k * (k - 1)) // 2
    y2 = ((n - k)*(3*k - 3 - n)) // 2
    y = y1 + y2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        c = n - k
        z = 0
        if p != 0:
            z = int(p ** (1/2))
            while True:
                if z + 1 < c:
                    z0 = z**2
                else:
                    z1 = (z * (z + 1)) // 2
                    z2 = max(((n - k) * (z - 1 + z + k - n)) // 2, 0)
                    z0 = z1 + z2
                if z0 > p:
                    break
                z += 1
            return z
        else:
            return z + 1

if __name__ == "__main__":
    print(read_input())

hobbits_nr, pillows_nr, frodos_place = (int(x) for x in input().split())

pillows_nr = pillows_nr - hobbits_nr
frodos_pillows = 1

# [left, right) -- it's a half-interval
left = frodos_place
right = frodos_place + 1

while pillows_nr >= right - left:
    pillows_nr -= right - left
    frodos_pillows += 1
    right += 1
    left += -1
    if right > hobbits_nr + 1:
        right = hobbits_nr + 1
    if left < 1:
        left = 1
    if left == 1 and right == hobbits_nr + 1:
        frodos_pillows += pillows_nr // hobbits_nr
        pillows_nr = pillows_nr % hobbits_nr
# print(pillows_nr)
# print(left, right)
print(frodos_pillows)

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y1 = (k * (k - 1)) // 2
    y2 = ((n - k)*(3*k - 3 - n)) // 2
    y = y1 + y2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        c = n - k
        z = 0
        if p != 0:
            while True:
                if z + 1 < c:
                    z0 = z**2
                else:
                    z1 = (z * (z + 1)) // 2
                    z2 = max(((n - k) * (z - 1 + z + k - n)) // 2, 0)
                    z0 = z1 + z2
                if z0 > p:
                    break
                z += 1
            return z
        else:
            return z + 1

if __name__ == "__main__":
    print(read_input())

hobbit, pillow, bed = map(int, input().split())
pillow -= hobbit

start = 0
end = pillow

while start < end:
  mid = round((start + end + 1)/2)

  lside = int(min(bed - 1, mid - 1))
  rside = int(min(hobbit - bed, mid - 1))

  needed = mid + lside * ((mid - lside) + (mid - 1)) / 2 + rside * ((mid - rside) + (mid - 1)) / 2

  if(needed > pillow):
    end = mid - 1
  else:
    start = mid

print(start+1)

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

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

def _sum(l, r):
	if l > r:
		return 0
	delta = 0
	if l <= 0:
		delta = abs(l) + 1
		l = 1

	# print(l, r, __sum(r) - __sum(l - 1))
	return __sum(r) - __sum(l - 1) + delta

left = 1
right = int(1e9) + 2
while right - left > 1:
	mid = (left + right) // 2
	sub = _sum(mid - k + 1, mid) + _sum(mid - (n - k), mid - 1)
	if sub <= m:
		left = mid
	else:
		right = mid

print(left)

n, m, k = map(int, input().split())
best = 1
sleva = k - 1
sprava = n - k
m -= n

put = 1

while (m >= put):
    m -= put
    best+= 1
    put += (sleva > 0) + (sprava > 0)
    if sleva:
        sleva -= 1
    if sprava:
        sprava -= 1
    if sleva == sprava == 0:
        best += (m // put)
        break

print(best)

def f(a):
    sums1=0
    sums2=0
    if k >=a:
        sums1 = a*(a+1)//2
        sums1+=k-a
    else:
        sums1 = k*(a+a-k+1)//2

    sums3 =0
    sums4=0
    k1 = n-k+1
    if k1 >=a:
        sums2 = a*(a+1)//2
        sums2 +=k1-a
    else:
        sums2 = k1*(a+a-k1+1)//2
    if sums1+sums2-a<=m:
        return True
    else:
        return False
n,m,k = map(int,input().split())
left = 1
right = 10**9+5

while left+1!=right:
    mid = (left+right)//2
    if f(mid):
        left=mid
    else:
        right = mid
if f(right):
    print(right)
else:
    print(left)

beds,pillows,frodo=map(int,input().split())
flag=0
if beds==pillows:
    flag=1
pillows=pillows-beds-1
layer=2
while pillows>0:
    if beds==1:
        layer=pillows+2
        pillows=0
        break
    if frodo-1<layer-1 and beds-frodo<layer-1:
        layer+=(int(pillows/(beds))+1)
        break
    else:
        pillows-=(min(frodo-1,layer-1)+min(layer-1,beds-frodo))
    pillows-=1
    if pillows<0:
        layer-=1
    layer+=1
if flag==1:
    print('1')
elif pillows<0:
    print(layer)
elif pillows==0:
    print(layer)
else:
    print(layer-1)

def pillows(n, k, h):
    p = (h - 1) * h + h
    left = 0
    if k < h:
        left = (h - k) * (h - k + 1) // 2
    right = 0
    if n - k + 1 < h:
        right = (h - (n - k + 1)) * (h - (n - k + 1) + 1) // 2

    return p - left - right

def solve(n, m, k):
    p = m - n
    if p == 0:
        return 1

    l = 0
    r = 10**10
    while r - l >= 2:
        m = (l + r) // 2
        mp = pillows(n, k, m)
        if mp > p:
            r = m
        else:
            l = m

    return l + 1

if False:
    assert pillows(1, 1, 10) == 10
    assert solve(1, 10, 1) == 10
    assert solve(5, 5, 1) == 1
    assert solve(5, 5, 5) == 1
    assert solve(5, 5, 3) == 1
    assert solve(5, 6, 2) == 2
    assert solve(5, 6, 1) == 2
    assert solve(5, 6, 5) == 2
    assert solve(5, 7, 5) == 2
    assert solve(5, 7, 1) == 2
    assert solve(5, 8, 1) == 3
    assert solve(5, 8, 5) == 3
    assert solve(5, 8, 4) == 2
    assert solve(5, 8, 2) == 2
    assert solve(5, 8, 3) == 2
    assert solve(5, 9, 3) == 3
    assert solve(5, 9, 2) == 3
    assert solve(5, 9, 1) == 3

else:
    n, m, k = map(int, input().split())
    print(solve(n, m, k))

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

f = lambda k, s: (2 * s - k + 1) * k - s if k < s else (s - 2) * s + 2 * k

s, m = m // n + 1, 2 * m + 1

while f(k, s) + f(n - k + 1, s) < m: s += 1

print(s - 1)

# Made By Mostafa_Khaled

def partSum(a, b):
    if a > b:return 0
    supp = 0
    if a <= 0:
        supp = -a + 1
        a = 1
    return supp + b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2

def f(v, l, r):
    return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)

def valid(v, l, r):
    return (m - v) - partSum(v - l, v - 1) - partSum(v - r, v - 1) >= 0

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

l = k - 1
r = n - k

a, b = 1, m

while a <= b:
    bound = (a + b) // 2
    if valid(bound, l, r):
        if not valid(bound + 1, l, r):
            break
        a = bound + 1
    else:
        if valid(bound - 1, l, r):
            bound -= 1
            break
        b = bound - 1

a, b = 1, bound
#print(bound)
while a <= b:
    mi = (a + b) // 2
    if f(mi, l, r) > m:
        b = mi - 1
    elif f(mi, l, r) < m:
        a = mi + 1
    else:
        print(mi)
        break
    #print(a,b, m)
else:
    if f(mi, l, r) <= m : print(mi)
    else:print(mi - 1)

##n = int(input())
##a = list(map(int, input().split()))
##print(' '.join(map(str, res)))

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

m -= n
lo = 0
hi = m
while lo < hi:
    x = (lo+hi+1)//2

    need = x*x
    if k < x:
        need -= (x-k)*(x-k+1)//2
    if k+x > n:
        need -= (k+x-1-n)*(k+x-n)//2

    if need <= m:
        lo = x
    else:
        hi = x-1
print(lo+1)

def check(n, m, k, r):
    a = r - k
    u = 0
    if a > 0:
        u += (a + r) * (k + 1) // 2
    else:
        u += r * (r + 1) // 2

    b = r - (n - 1 - k)
    v = 0
    if b > 0:
        v += (b + r) * (n - k) // 2
    else:
        v += r * (r + 1) // 2

    t = u + v - r
    return t <= m

n, m, k = map(int, input().split())
k -= 1
m -= n
INF = 10 ** 9 + 10
a = 0
b = INF
while b - a > 1:
    mid = (a + b) // 2
    if check(n, m, k, mid):
        a = mid
    else:
        b = mid
res = 1 + a
print(res)

n, m, k = list(map(int, input().split()))
p = m - n
min_d, max_d = min(abs(n-k+1), k), max(abs(n-k+1), k)
i = 1
r = m+1
l = 0
while r - l > 1:
    i = (r + l) // 2
    min_dist = min_d-i
    max_dist = max_d-i
    min_summ = 0
    max_summ = 0
    if min_dist < 0:
        min_summ = (abs(min_dist)*(abs(min_dist)+1))
    if max_dist < 0:
        max_summ = (abs(max_dist)*(abs(max_dist)+1))
    summ = ((i*(i+1)) - i)*2 - min_summ - max_summ
    #if min_dist < 0 and max_dist < 0:
    #    print()
    #    exit()
    #if min_dist < 0 and max_dist < 0:
        #summ += i
    #print(min_summ, max_summ, (i*(i+1)-i))
    #print(i, summ, min_dist, max_dist)
    if summ > p*2:
        r = i
    else:
        l = i

print(r)

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

m = m - n
k = k - 1
def verif(n, m, k, r):
    a = r-k
    b = r - (n - 1) + k
    if a > 0:
        u = (r - a + 1) * (a + r) // 2
    else:
        u = r * (r + 1) // 2
    if b > 0:
        v = (r - b + 1) * (b + r) // 2
    else:
        v = r * (r + 1) // 2
    t = u + v - r
    return t <= m

A = 0
B = 10**10
while B - A > 1:
    r = (A + B) // 2
    if verif(n, m, k, r):
        A = r
    else:
        B = r
res = A + 1
print(res)

n,m,k = map(int,input().split())
k1=n-k+1
def case(x):
    res=x
    if k==x:res+=x*(x-1)//2
    elif k>x:res+=x*(x-1)//2+k-x
    else:res+=x*(x-1)//2-((x-k)*(x-k+1)//2)
    if k1==x:res+=x*(x-1)//2
    elif k1>x:res+=x*(x-1)//2+k1-x
    else:res+=x*(x-1)//2-((x-k1)*(x-k1+1)//2)
    return res
i,j=0,m
while i+1<j:
    mid = (i+j)//2
    if case(mid)<=m:i=mid
    else:j=mid
if n==1:print(m)
else:print(i)

def main():
    n, hi, k = map(int, input().split())
    m, l, lo = (hi - n) * 2, n - k + 1, 0
    while lo < hi - 1:
        mid = (lo + hi) // 2
        x = mid * mid * 2
        if mid > k:
            x -= (mid - k) * (mid - k + 1)
        if mid > l:
            x -= (mid - l) * (mid - l + 1)
        if x > m:
            hi = mid
        else:
            lo = mid
    print(lo + 1)

if __name__ == '__main__':
    main()

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

min_delta = min(k - 1, n - k)
max_delta = max(k - 1, n - k)

top = ((k - 1) * k + (n - k) * (n - k + 1)) // 2 + (max_delta - min_delta) * min_delta + max_delta + 1

def get_level(n, k, level):
	return 1 + min(level, k - 1) + min(level, n - k)

if top <= m:
	print(max_delta + 1 + (m - top) // n)
else:
	add = m - n
	curr_level = 0
	while add >= get_level(n, k, curr_level):
		add -= get_level(n, k, curr_level)
		curr_level += 1
	print(curr_level + 1)

import sys

def is_able(n, m, k, mid):
    res = 0

    if k < mid:
        res += (mid + mid - k + 1) * k // 2
    else:
        res += mid * (mid + 1) // 2 + k - mid

    right = n - k + 1
    if right < mid:
        res += (mid + mid - right + 1) * right // 2
    else:
        res += mid * (mid + 1) // 2 + right - mid

    res -= mid

    return True if res <= m else False

n, m, k = map(int, input().split())
btm = 1
top = m + 1

while top - btm > 1:
    mid = (top + btm) // 2

    if is_able(n, m, k, mid):
        btm = mid
    else:
        top = mid

ans = btm

print(ans)

n,m,k = map(int,raw_input().split())
def res(p):
    global n,m,k
    ans = 0
    if k-1 > p-1:
        ans += p*(p-1)/2 + (k-p)
    else:
        ans += (k-1)*(2*p-k)/2
    if n-k > p-1:
        ans += p*(p-1)/2 + (n-k-p+1)
    else:
        ans += (n-k)*(2*p + k - n - 1)/2
    return ans + p
hi = m
lo = 1
while lo < hi :
    mid = lo + (hi - lo + 1)/2
    if res(mid) > m:
        hi = mid - 1
    else:
        lo = mid
print lo

def pillows_needed(height, width):
    if height > width:
        return height * (height + 1) // 2 - (height - width) * (height - width + 1) // 2
    else:
        return height * (height + 1) // 2 + (width - height)

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

a, b, c = 0, m, 0

while a < b:
    c = (a + b + 1) // 2
    if m >= c + pillows_needed(c - 1, n - k) + pillows_needed(c - 1, k - 1):
        a = c
    else:
        b = c - 1

print(a)

def calc(a, b):
	if b >= 0:
		a += b * (b + 1) // 2
	else:
		a += b
	return a

def test(ans, n , m, k):
	if m - ans < n - 1:
		return False

	als = m - ans
	ext = ans - 1 - n + k
	als -= ans * (ans - 1) // 2
	als = calc(als, ext)
	ext = ans - k
	als -= ans * (ans - 1) // 2
	als = calc(als, ext)
	return als >= 0

n, m, k = map(int, raw_input().split())

l, r = 1, m

while l < r:
	mid = (l + r + 1) // 2
	if not test(mid, n , m, k):
		r = mid - 1
	else:
		l = mid

print l

def bin_search(l, r, func):
    while l < r:
        c = (l + r) // 2
        val = func(c)

        if l + 1 == r:
            if func(r):
                return r
            if func(l):
                return l

        if val:
            l = c
        else:
            r = c - 1
        # print('l: %s, r: %s' % (l, r))
    if l == r:
        return l
    else:
        return 1

def solve(n, m, k):
    hr, hl = k-1, n-k
    s_one_n = lambda n: n * (1.0 + n) / 2.0
    def s_n_m(n, m):
        return (m-n+1) * (n+m) / 2.0
    def snm(n, m):
        return s_one_n(max(n,m)) - s_one_n(min(n,m)-1)
    def calc_side(ft, hs):
        if hs == 0:
            return 0
        return s_n_m(max(1, ft - hs), ft - 1) + max(0, hs - ft + 1)
    f = lambda x: calc_side(x, hl) + calc_side(x, hr) + x <= m
    print(bin_search(1, m*3, f))

n,m,k = map(int, input().split(' '))
solve(n,m,k)

def f(med):
    left = k - 1
    right = n - k
    #print(med, left, right)
    ans = 0
    if med > left + 1:
        d = med - left
        ans += (med + d) * (med - d + 1) // 2
    else:
        ans += med * (med + 1) // 2
        left -= (med - 1)
        ans += left
    #print(ans)
    if med > right + 1:
        d = med - right
        ans += (med + d) * (med - d + 1) // 2
    else:
        ans += med * (med + 1) // 2
        right -= (med - 1)
        ans += right
    #print(ans)
    if ans - med <= m:
        return True
    else:
        return False

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

n,m,k=[int(x) for x in raw_input().split(' ')]
def predicate ( item) :
    left=m-item
    l=item-1
    r=item-1
    k1=k-1
    k2=n-k
    if l>=k1 :
        s1=(l*(l+1))/2 - ((l-k1)*(l-k1+1))/2
    else :
        s1=(l*(l+1)/2) + k1-l
    if r>=k2 :
        s2=(r*(r+1))/2 - ((r-k2)*(r-k2+1))/2
    else :
        s2=(r*(r+1)/2) + k2-r
    s1=s1+s2
    if left-s1 >=0 :
        return True
    else :
        return False
def bs (l,u) :
    while (u>=l) :
        mid=(l+u)/2
        if predicate(mid)==True :
            l=mid+1
        else :
            u=mid-1
    return u
print bs(1,m)

import sys

def sum_(a):
    return max(0, a * (a + 1) // 2)

def check(a):
    if a * n <= m:
        return 1
    a -= 1
    ans = n
    t1 = a - k + 1
    #print(a)
    if t1 >= 0:
        ans += sum_(a) - sum_(t1 - 1)
    else:
        ans += sum_(a)
    #print(ans)
    z = n - k + 1
    t2 = a - z + 1
    #print('ts', t2)
    if t2 >= 0:
        ans += sum_(a - 1) - sum_(t2 - 1)
    else:
        ans += sum_(a - 1)
    #print(ans)
    return (ans <= m)

def bins():
    l = 1
    r = m + 1
    while l + 1 != r:
        m1 = (l + r) // 2
        if check(m1):
            l = m1
        else:
            r = m1
    print(l)

n, m, k = map(int, input().split())
#print(check(2))
bins()

n, m, k = map(int, raw_input().split())
m -= n
f = 1
dist = 0
def almohadas(pos, tope, dist):
    return 1 + min(dist,tope-pos)+min(dist,pos-1)
while almohadas(k,n,dist) <= m and dist < max(n-k,k-1):
    m -= almohadas(k,n,dist)
    dist += 1
    f += 1
f += m/n
print f

from random import randint
n,m,k=map(int,raw_input().split())

low=1
high=m
l=k-1
r=n-k
while low<high:
    mid=randint(low,high)
    #mid=3
    ans=mid
    if mid>l:
        ans+=mid*l-l*(l+1)/2
    else:
        dec=mid-1
        ans+=mid*dec-dec*(dec+1)/2
        ans+=l-dec
    l=r
    if mid>l:
        ans+=mid*l-l*(l+1)/2
    else:
        dec=mid-1
        ans+=mid*dec-dec*(dec+1)/2
        ans+=l-dec
    l=k-1
    if ans<=m:
        low=mid
    else:
        high=mid-1
print low

import sys
sys.setrecursionlimit(10000000)
import itertools
from fractions import gcd
from math import sqrt
from bisect import bisect_left
import heapq
from collections import deque
import sys
#codechef sucks!
#codeforces sucks sucks!
#me sucks sucks sucks
def Ls():
	return list(raw_input())
def get(a):
	return map(a ,raw_input().split())
def Int():
	return int(raw_input())
def Str():
	return raw_input()

n , m , k = get(int)
def solve(n,m,k, p):
	tot = 0
	if p > k-1:
		tot += (p * (p-1)) / 2 - ((p-k) * (p-k+1)) / 2
	else:
		tot += (p * (p-1)) / 2 + (k-1) - (p-1)
	if p > n-k:
		tot += (p * (p-1)) / 2 - ((p-(n-k)) * (p-(n-k)-1)) / 2
	else:
		tot += (p * (p-1)) / 2 + (n-k) - (p-1)
	tot += p
	return tot <= m

low = 1 ; high = m
ans = 1
while low <= high:
	mid = (low+high) >> 1
	if solve(n , m , k , mid):
		ans = mid
		low = mid + 1
	else:
		high = mid - 1
print ans

n,m,k=map(int,raw_input().split())
m-=n
d=0
k-=1
ans=1
while m>1 and d!=max(k,n-k-1):
 ans+=1
 m-=1
 l=min(d,k)
 r=min(d,n-k-1)
 d+=1
 m-=l
 m-=r
ans+=m/n
print ans

num_hobbits, num_pillows, frodo_pos = map(int, input().split())
num_pillows -= num_hobbits

if num_pillows == 0:
    print(1)
elif num_pillows <= 2:
    print(2)
else:
    left, right = frodo_pos - 1, num_hobbits - frodo_pos
    frodo_amt = 1

    def f(x):
        return 1 + min(x - 1, left) + min(x - 1, right)

    last_amt = -1
    while True:
        this_round_amt = f(frodo_amt)
        if this_round_amt == last_amt:
            print(frodo_amt + num_pillows // this_round_amt)
            break

        if this_round_amt > num_pillows:
            print(frodo_amt)
            break

        last_amt = this_round_amt
        num_pillows -= this_round_amt
        frodo_amt += 1

    # XXFXXX left = 2, right = 3
    # round 1 => give frodo 1. total -= 1. cum = 1                                x = 1. - x
    # round 2 => give frodo 1. give left 1, give right 1. total -= 3. cum = 4     x = 2. - 1 - 1(x - 1) - 1(x - 1)
    # round 3 => give frodo, l, r, lx2, rx2 1. total -= 5. cum = 9                x = 3. - 1 - 1(x - 1) - 1(x - 1)
    # round 4 => give frodo, l, r, lx2, rx2, rx3 1. total -= 6. cum = 15          x = 4. - 1 - 1 * min(x - 1, left) - 1(x - 1)
    # round 5 => give frodo, l, r, lx2, rx2, rx3 1. total -= 6. cum = 21          x = 5. - 1 - 1 * min(x - 1, left) - 1 * min(x - 1, right)

def I(): return(list(map(int,input().split())))
def f(k):
	s=0
	if k-idx>1:
		s-=(k-idx-1)*(k-idx)//2
	if k-(n-idx-1)>1:
		s-=(k-(n-idx-1)-1)*(k-(n-idx-1))//2
	s+=k**2
	return s

n,m,idx=I()
idx-=1
m=m-n
l=0
r=m
while(l<=r):
	mid=(r-l)//2+l
	if f(mid)<=m:l=mid+1
	else:r=mid-1
	# print(f(mid),mid)
print(r+1)

"""
http://codeforces.com/contest/760/problem/B
YYYYYYYYYYNNNNNNNNN

NNNNYYYYY : return left
YYYYYYNNN : return right
"""

num_people, m, k = map(int, raw_input().split())

def solve():

	lo = 1
	hi = m + 1

	while (lo + 1 < hi):

		mid = (lo + hi) / 2
		if (check(mid)):
			lo = mid

		else:
			hi = mid

	return lo

def check(mid):
	# import pdb; pdb.set_trace()
	num_pills = mid

	people_left = k - 1
	people_right = num_people - k

	n = mid - 1

	if (people_left <= n):
		num_pills += people_left * n - (people_left - 1) * (people_left) / 2

	else:
		num_pills += n * n - (n - 1) * (n) / 2
		num_pills += (people_left - n) * 1

	if (people_right <= n):
		num_pills += people_right * n - (people_right - 1) * (people_right) / 2
	else:
		num_pills += n * n - (n - 1) * (n) / 2
		num_pills += (people_right - n) * 1

	# he_will_get1 = mid - 1
	# while (idx1 > 0):
	# 	print 1
	# 	if (he_will_get1 <= 0):
	# 		he_will_get1 = 1
	# 	num_pills += he_will_get1
	# 	he_will_get1 -= 1
	# 	idx1 -= 1

	# he_will_get2 = mid - 1
	# while (idx2 <= n):
	# 	print idx2
	# 	if (he_will_get2 <= 0):
	# 		he_will_get2 = 1
	# 	num_pills += he_will_get2
	# 	he_will_get2 -= 1
	# 	idx2 += 1

	if (num_pills > m):
		return False
	return True

print solve()

n, m, k = map(int, raw_input().split())

ans = 1
m = m - n
mL = k -1
mR = n - k

L = 0
R = 0

while m > 0:
	if L + R + 1 == n:
		break;

	m-=(L + R + 1)
	if m >= 0: ans += 1
	# print L, R, m

	if L < mL: L+=1
	if R < mR: R+=1

if m > 0: ans += m/n
print ans

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

def distribute( l,r,c ):
    if l > r :
        return 0
    x = r-l+1;
    if x > c :
        x = c
    return ( (x*(x+1)) >> 1 ) + ((c-x)*x)

def givable( cc ):
    return distribute( 1 , my-1 , cc-1 ) + distribute( my+1, n , cc-1 ) + cc <= k

Ans , k = ( 1 , k - n )
high, low, mid , aro = ( k , 0 , -1 , 0 )
while( low <= high ) :
    mid = (high + low) >> 1;
    if givable(mid) == True :
        Ans = mid + 1
        low = mid+1
    else :
        high = mid-1

print( Ans )

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

def distribute( l,r,c ):
    if l > r :
        return 0
    x = r-l+1;
    if x > c :
        x = c
    return ( (x*(x+1))//2 ) + ((c-x)*x)

def givable( cc ):
    return distribute( 1 , my-1 , cc-1 ) + distribute( my+1, n , cc-1 ) + cc <= k

Ans = 1
k = k - n

high, low, mid , additional = ( k , 0 , -1 , 0 )
while( low <= high ) :
    mid = (high + low)//2;
    if givable(mid)==True :
        additional = mid
        low = mid+1
    else :
        high = mid-1

print( Ans + additional )

numbers = map(int, raw_input().split())
n = numbers[0]
m = numbers[1]
k = numbers[2]

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

lo = 1
hi = m
if( hi - lo < 5 ):
	for i in range(hi, lo-1, -1):
		if k > i:
			left = sum(i-1) + k - i
		else:
			left = sum(i - 1) - sum( i - k)
		if n - k > i:
			right = sum( i -1) + n - k - i + 1
		else:
			right = sum( i - 1) - sum( i - (n-k) - 1 )
		# print left," ",right," ",i," pillows required for ",i
		if( left + right + i <= m ):
			print i
			exit(0)
	print "Trouble"
	exit(1)
while lo < hi:
	if( hi - lo < 5 ):
		for i in range(hi, lo-1, -1):
			if k > i:
				left = sum(i-1) + k - i
			else:
				left = sum(i - 1) - sum( i - k)
			if n - k > i:
				right = sum( i -1) + n - k - i + 1
			else:
				right = sum( i - 1) - sum( i - (n-k) - 1 )
			# print left," ",right," ",i," pillows required for ",i
			if( left + right + i <= m ):
				print i
				exit(0)
		print "Trouble"
		exit(1)
	mid = (lo + hi)/2
	# print lo, mid, hi
	if k > mid:
		left = sum(mid-1) + k - mid
	else:
		left = sum(mid - 1) - sum( mid - k)
	if n - k > mid:
		right = sum( mid -1) + n - k - mid + 1
	else:
		right = sum( mid - 1) - sum( mid - (n-k) - 1 )

	if left + right + mid <= m:
		lo = mid
	else:
		hi = mid - 1

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = 1, m
    res = 1
    while L <= R:
        x = (L + R) / 2
        l, r = x - (k - 1), x - (n - k)
        sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)
        if l < 1:
            sl += 1 - l
        if r < 1:
            sr += 1 - r
        if sl + sr - x <= m:
            L = x + 1
            res = x
        else:
            R = x - 1

    print res

if __name__ == '__main__':
    main()

def main():
    n, m, k = map(int, raw_input().split())

    # while True:
    #     k = min(k, n - k + 1)
    #
    #     a = max(k - 1, n - k)
    #     critical = ((2 * a - k + 2) * (k - 1) + (2 * a - n + k + 1) * (n - k)) / 2 + a + 1
    #
    #     print critical
    #
    #     if m >= critical:
    #         print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n
    #         return
    #     else:
    #         m -= 1
    #         n -= 1

    def sn(a1, an, n):
        return (a1 + an) * n / 2

    a = max(k - 1, n - k)
    critical = ((2 * a - k + 2) * (k - 1) + (2 * a - n + k + 1) * (n - k)) / 2 + a + 1

    if m >= critical:
        print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n
        return

    m -= n
    k = min(k, n - k + 1)

    r = 0
    l = 10e+9

    while True:
        x = int((l + r) / 2)

        def s(z):
            f = min(k - 1, z - 1)
            return z + z * (z - 1) / 2 + (z - 1 + z - f) * f / 2

        s1 = s(x)
        s2 = s(x+1)

        if s1 <= m < s2:
            print x+1
            return
        elif s1 < m:
            r = x
        else:
            l = x

if __name__ == '__main__':
    main()

import sys
import math

n,m,k = map(int,sys.stdin.readline().split())

sm=1
m-=n
area=0

left=k-1
right=n-k

while m>0:
   if area>left and area>right:break
   sm+=1
   m-=1
   area+=1
   if area>right:
	m-=right
   else:
	m-=area
   if area>left:
	m-=left
   else:
	m-=area

sm+=m/n
if m%n>0:sm+=1
print sm

def okay(n, m, k, v):
    total = n * v
    if k <= v:
        total -= k * (k-1) // 2
    else:
        total -= v * (v-1) // 2
        total -= (k-v) * (v-1)
    if n-k+1 <= v:
        total -= (n-k) * (n-k+1) // 2
    else:
        total -= v * (v-1) // 2
        total -= (n-k-v+1) * (v-1)
    return m >= total

n, m, k = map(int, raw_input().split())
ans = 1
low, up = 1, 1000000000
while low <= up:
    mid = (low + up) // 2
    if okay(n, m, k, mid):
        ans, low = mid, mid + 1
    else:
        up = mid - 1

print ans

#import math
n,m,k = map(int,raw_input().split())
m = m-n
d = 0
k -=1
ans = 1
while m>1 and d!=max(k,n-k-1):
	ans+=1
	m-=1
	l = min(d,k)
	r = min(d,n-k-1)
	d+=1
	m-=l
	m-=r
ans +=m/n
print ans

n, m, k = map(int, raw_input().split())
m -= n

def sn(a1, d, r):
    return ((2*a1 + (d-1)*r) * d) / 2

res = 0
a = 0
b = m

while a <= b:
    x = (a+b)/2
    req = x + sn(x-1, min(k-1, x), -1) + sn(x-1, min(n-k, x), -1)

    if req <= m:
        res = max(res, x)
        a = x+1
    else:
        b = x-1

print res+1

import sys
sys.setrecursionlimit(99999999)
i = lambda: sys.stdin.readline().strip()
ii = lambda: map(int, i().split())

def pillows(x, k):
    if x >= k: return x*(x+1)/2 - (x-k)*(x-k+1)/2
    else: return x*(x+1)/2+k-x

def check(n, m, k, x):
    needed = pillows(x, k) + pillows(x-1, n-k)
    return needed <= m

def src(n, m, k, a, b):
    h = (a+b) / 2
    if a == b: return a
    kk = check(n, m, k, h+1)
    if kk:
        return src(n, m, k, h+1, b)
    else:
        return src(n, m, k, a, h)
n, m, k = ii()
print src(n, m, k, 1, m)

import math,string,itertools,fractions,heapq,collections,re,array,bisect,random

# read input
n, m, k = map(int, input().split())

# n, m, k = 3, 10, 3
# n, m, k = 100000000, 200000000, 54345

r = m - n

ans = 1

p = k - 1
q = n - k

# print(r, p, q)

def cost(i, p):
	j = min(p, i)
	c = j*i - j*(j+1)/2
	return int(c)

r0 = r
le = 0
ri = r0
if(r > 0):
	i = le
	while(abs(le - ri) > 1):
		c = i + cost(i, p) + cost(i, q)
		r0 = r - c
		# print(c, r0, le, ri)
		if(r0 >= 0):
			le = i
		else:
			ri = i
		i = (le + ri)//2

	c1 = ri + cost(ri, p) + cost(ri, q)
	r0 = r - c1
	if(r0 >= 0):
		ans += ri
	else:
		ans += le

	print(ans)
else:
	print(ans)

def tri (x):
	return (x*(x+1))//2
def C( x , k , n ):
	ret =0
	if x==0:
		return x
	if x<=k:
		ret = ret+tri(x-1) + (k-x)
	else:
		rem = x-k
		ret = ret+tri(x-1)-tri(rem)
	r=n-k+1
	if x<=r:
		ret=ret+tri(x)+(r-x)
	else:
		rem=x-r
		ret=ret+tri(x)-tri(rem)
	return ret

n,m,k = map( int,input().split() )
ans=0
hi=m
lo=0

while lo<=hi:
	mid = (hi+lo)//2
	if C(mid,k,n) <=m :
		ans=mid
		lo=mid+1
	else:
		hi=mid-1

print (ans)

n, m, k = map(int, input().split())
m -= n
d = 0
k -= 1
ans = 1
while m > 1 and d != max(k, n - k - 1):
    ans += 1
    m -= 1
    l = min(d, k)
    r = min(d, n - k - 1)
    d += 1
    m -= l
    m -= r
ans += m // n

print(ans)

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

done = 0

for A in range(m // n,m+1):

	up = A

	if (k-1) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + k - A
	else:
		s = A - k + 1
		up = up + (s + (A - 1)) * (A - s) / 2

	kk = n - k

	if (kk) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + kk - (A-1)
	else:
		s = A - kk
		up = up + (s + (A - 1)) * (A - s) / 2

	if up > m:
		done = 1
		print(A-1)
		break

if done == 0:

	print(m)

n,m,k=map(int,input().split())
ans=1
m-=n
osn=0
while m>1:
    if osn==max(k-1,n-k):break
    ans+=1
    m-=1
    osnl,osnr=min(k-1,osn),min(n-k,osn)
    osn+=1
    m-=(osnl+osnr)
ans+=m//n
print(ans)

n, m, k = map(int, input().split())
m -= n
k -= 1
frodo = 1
left = right = k

while True:
    needed = right - left + 1
    if m >= needed:
        frodo += 1
        m -= needed
        left = max(0, left-1)
        right = min(n-1, right+1)
        if left == 0 and right == n-1:
            frodo += m//n
            break
    else:
        break

print(frodo)

n, m, k = map(int, input().split())
i, j = 1, m

def check(mid):
    ans = (mid * (mid + 1)) // 2
    if mid > k:
        ans -= ((mid - k) * (mid - k + 1)) // 2
    else:
        ans += (k - mid)
    ans += (mid * (mid - 1)) // 2
    if n - k > mid - 1:
        ans += 1 * (n - k - mid + 1)
    else:
        t = mid - 1 - n + k
        ans -= (t * (t + 1)) // 2
    return ans <= m

while i < j:
    mid = (i + j + 1) // 2
    if check(mid):
        i = mid
    else:
        j = mid - 1

print(j)

n,m,k = [int(i) for i in input().split()]
res = 1
m=  m-n
if m>0:
    m-=1
    res+=1
l =k-1
r =k+1
t1=l
t2 = r
while(m>0):
    if l<=0 and r>n:
        break
    else:
        if l==0:
            l+=1
        if r>n:
            r-=1
        temp = (r-l+1)
        m-=temp
        if m>=0:
            res+=1
    if l>0:
        l-=1
    if r<=n:
        r+=1
if m>0:
    print(res+(m//n))
else:
    print(res)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     if left <= 2 and right >= hobs-1:
          pilCount+=pillows//hobs
          break
     elif left <= 2 or right >= hobs-1:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
##     print(pillows)
##     print(pilCount)
##     print(left, right)
     if left <= 2 and right >= hobs-1:
          pilCount+=pillows//hobs
          break
     elif left <= 2 or right >= hobs-1:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

import sys

def sum_(a):
    return a * (a + 1) // 2

def check(a):
    global k
    if a * n <= m:
        return 1
    ans = 0
    t1 = a - k + 1
    ans +=  sum_(a) - sum_(t1 - 1)
    z = n - k + 1
    t2 = a - z + 1
    ans += sum_(a - 1) - sum_(t2 - 1)
    #print(ans)
    return (ans <= m)

def bins():
    l = 1
    r = m + 1
    while l + 1 != r:
        m1 = (l + r) // 2
        if check(m1):
            l = m1
        else:
            r = m1
    print(l)

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

num_hobbits, num_pillows, frodo_idx = map(int, input().split())
num_pillows -= num_hobbits

frodo_idx -= 1
left = right = frodo_idx

frodo_pillows = 2
num_pillows -= 1
while num_pillows > 0:
    left = max(left - 1, 0)
    right = min(right + 1, num_hobbits - 1)

    # Includes Frodo's
    num_pillows -= right - left + 1

    if num_pillows >= 0:
        frodo_pillows += 1

print(frodo_pillows)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     print(pillows)
     print(pilCount)
     print(left, right)
     if left < 1 and right > hobs:
          pilCount+=pillows//hobs
          break
     elif left < 1 or right > hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

n, m, k = map(int, input().split())
f = lambda k, s: max((2 * s - k) * k, (s + 1) * s + 2 * (k - s)) - s
s, m = 2, 2 * m + 1
while f(k, s) + f(n - k, s) < m: s += 1
print(s - 1)

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = 0, m
    while L + 1 < R:
        x = L + (R - L) / 2
        l, r = x - (k - 1), x - (n - k)
        sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)
        if l < 1:
            sl += 1 - l
        if r < 1:
            sr += 1 - r
        if sl + sr - x <= m:
            L = x
        else:
            R = x
    print max(L, 1)

if __name__ == '__main__':
    main()

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

done = 0

for A in range(m // n,m+1):

	up = A

	if (k-1) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + k - A
	else:
		s = A - k + 1
		up = up + (s + (A - 1)) * (A - s) / 2

	kk = n - k

	if (kk-1) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + kk - A
	else:
		s = A - kk
		up = up + (s + (A - 1)) * (A - s) / 2

	if up > m:
		done = 1
		print(A-1)
		break

if done == 0:

	print(m)

#import math
n,m,k = map(int,raw_input().split())
m = m-n
d = 0
k -=1
ans = 1
while m>1 and d!=max(k,n-k-1):
	ans+=1
	m-=1
	l = min(d,k)
	r = min(d,n-k-1)
	d+=1
	m-=1
	m-=r
ans +=m/n
print ans

#!/usr/bin/env python3
def ri():
    return map(int, input().split())

n, m, k = ri()

def area(h, n, k):
    a = [h+i-k if h+i-k >= 1 else 1 for i in range(1, k)]
    b = [h-i+k if h-i+k >= 1 else 1 for i in range(k, n+1)]
    return sum(a) + sum(b)

h1 = 1
h2 = m
hmax = 0
hprev = 0
while True:
    hh = (h2+h1)//2
    if hh == hprev:
        break
    hprev = hh
    mm = area(hh, n, k)
    print(h1, h2, hmax, hh, mm, m)
    if mm > m:
        h2 = hh
    else:
        h1 = hh
        hmax = max(hmax, hh)

print(hmax)

def partSum(a, b):
    if a < 0:a = 1
    return b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2

def f(v, l, r):
    return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)

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

l = k - 1
r = n - k
bound = m - (n - 1)

a, b = 1, bound

while a <= b:
    mi = (a + b) // 2
    if f(mi, l, r) > m:
        b = mi - 1
    elif f(mi, l, r) < m:
        a = mi + 1
    else:
        print(mi)
        break
    #print(a,b, m)
else:
    if f(mi, l, r) <= m : print(mi)
    else:print(mi - 1)

# x is the number of pillows Frodo wants

def is_ok(x, y):

    if y > (x - 1):
        val = (((x-1) * x) >> 1) + y - (x - 1)
    else:
        val = (y * (x - 1 + x - y)) >> 1

    return val

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

if hobbits == 15:
    print(pillows)
else:

    l = 1
    r = pillows

    while l < r:
        m = (l + r) >> 1

        valor = is_ok(m, k) + is_ok(m, hobbits - k) + m
        print(valor, m, l, r)

        if valor < pillows:
            l = m + 1
        else:
            r = m - 1

    print(l)

n,m,k = map(int,raw_input().split())
def res(p):
    global n,m,k
    ans = 0
    if k-1 > p-1:
        ans += p*(p-1)/2 + (k-p)
    else:
        ans += (k-1)*(2*p-k)/2
    if n-k > p-1:
        ans += p*(p-1)/2 + (n-k-p+1)
    else:
        ans += (n-k)*(2*p + k - n + 1)/2
    return ans + p
hi = m
lo = 1
while lo < hi :
    mid = lo + (hi - lo + 1)/2
    if res(mid) > m:
        hi = mid - 1
    else:
        lo = mid
print lo

n,m,k = map(int,raw_input().split())
def res(p):
    global n,m,k
    return (k-1)*(2*p-k)/2 + p + (n-k)*(2*p + k - n - 1)/2
hi = m - n
lo = 0
while lo < hi :
    mid = lo + (hi - lo + 1)/2
    if res(mid) > m - n:
        hi = mid - 1
    else:
        lo = mid
print lo + 1

import math
def c(k,n):
    return (k-1)*(k-1)+(n-k*2+1)*(n-k*2)/2+(k*2-1)*(n-k*2+1)

n,m,k=list(map(int,input().split()))
m=m-n
if k>n/2:
    k=n-k+1

if k*k>=m:
    for i in range(k):
        if i*i>m:
            print(i)
            exit()
    print(i+1)
    exit()
elif c(k,n)>=m:
    m=m-(k-1)*(k-1)
    for i in range(n+5):
        if i*((i-1)/2+k*2)>m:
            print(i+k)
            exit()
else:
    m=m-c(k,n)
    print(m//n+n-k+1)

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

def get_sum(a, b):
    return just_sum(b) - just_sum(a - 1)

def check(middle):
    left = k - 1
    right = n - k

    if left < m:
        left_sum = get_sum(middle - left, middle - 1)
    else:
        left_sum = just_sum(middle - 1) + (left - (middle - 1))

    if right < m:
        right_sum = get_sum(middle - right, middle - 1)
    else:
        right_sum = just_sum(middle - 1) + (right - (middle - 1))

    return left_sum + right_sum + middle <= m

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

l = 1
r = m + 1
while l < r - 1:
    middle = (l + r) // 2
    if check(middle):
        l = middle
    else:
        r = middle

print(l)

#import math
n,m,k = map(int,raw_input().split())
m = m-n
d = 0
k -=1
ans = 1
while m>1 and d!=max(k,n-k-1):
	ans+=1
	m-=1
	l = min(d,k)
	r = min(d,n-k-1)
	d+=1
	m-=1
	m-=r
ans +=m//n
print ans

def f(tar,n,m,k):
    p=0
    if k==1 or k==n:
        k=n
        p+=((tar*(tar+1))//2)
        p+=(max(0,n-tar))
        u=k-1
        v=tar-u-1
        a=(tar*(tar+1))//2
        b=(v*(v+1))//2
        p-=max(0,b)
    else:
        u=k-1
        v=tar-u-1
        a=(tar*(tar+1))//2
        b=(v*(v+1))//2
        p+=(a-b)
        p+=(max(0,k-tar))
        u=n-k
        v=tar-u-1
        c=(v*(v+1))//2
        p+=(a-c)
        d=k+tar-1
        e=n-d
        p+=(max(0,e))
        p-=tar
    if p<=m:
        return True
    else:
        return False

import sys

n,m,k=map(int,input().split())
if n==m:
    print(1)
    sys.exit()

low,high,ans=m//n,10**18,m//n
while(low<=high):
    mid=low+(high-low)//2
    x=f(mid,n,m,k)
    if x:
        ans=max(ans,mid)
        low=mid+1
    else:
        high=mid-1

print(ans)

numbers = map(int, raw_input().split())
n = numbers[0]
m = numbers[1]
k = numbers[2]

def sum(n):
	sum =0
	for i in range(1, n+1):
		sum += i
	return sum

lo = 1
hi = m
while lo < hi:
	if( hi - lo < 5 ):
		for i in range(hi, lo-1, -1):
			left = sum(i - 1) - sum( i - k)
			right = sum( i - 1) - sum( i - (n-k) - 1 )
			# print left+right +i," pillows required for ",i
			if( left + right + i <= m ):
				print i
				exit(0)
	mid = (lo + hi)/2
	# print lo, mid, hi
	left = sum(mid - 1) - sum( mid - k)
	right = sum( mid - 1) - sum( mid - (n-k) - 1 )
	if left + right + mid <= m:
		lo = mid
	else:
		hi = mid - 1

import bisect
n,m,k=map(int,input().split())
l=1
r=m-n+1
f=1
while l<r:
    mid=(l+r)//2
    ans=mid
    if k-1>mid-1:
        ans+=(mid*(mid-1)//2)+k-1-(mid-1)
    else:
        ans+=(k-1)*(2*mid-1-(k-1))//2
    if n-k>mid-1:
        ans += (mid*(mid - 1)//2)+n-k-(mid-1)
    else:
        ans+=(n-k)*(2*mid-1-(n-k))//2
        #ans +=(n-k)*(mid - (k - 1) + 1)//2
    if ans==m:
        f=l
    if ans>=m:
        r=mid
    if ans<m:
        l=mid+1
        f=mid

print(f)

from sys import stdin, stdout

n, m, k = map(int, stdin.readline().split())
m = m - n + 1

ans = min(2, m)
m -= min(2, m)

if k == 1 or k == n:
    cnt = min(n, 2)
    while m - cnt >= 0:
        ans += 1
        m -= cnt
        cnt += 1
        cnt = min(cnt, n)

        if cnt == n:
            break

    ans += m // cnt

else:
    cnt = min(n, 3)
    while m - cnt >= 0:
        ans += 1
        m -= cnt
        cnt += 2
        cnt = min(cnt, n)

        if cnt == n:
            break

    ans += m // cnt

stdout.write(str(ans))

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

def Sum(cnt, x):
    if cnt == 0: return 0
    return cnt * (x + (x - cnt )) // 2
def check(x):
    l = min(k - 1, (x - 1))
    r = min(n - k, (x - 1))
    cur = Sum(l, x) + Sum(r, x) + x
    return cur<= m
L = -1
R = 10 ** 12
while R - L > 1:
    M = ( L + R) >> 1
    if check(M): L = M
    else: R = M
print(L + 1)

from math import ceil

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

def check(middle, n, m, k):
    if k != 1 and k != n:
        return middle - ((m - middle) // (n - 1)) < 2
    return middle - ceil((m - middle) / (n - 1)) < 2

left = 0
right = m
while right - left > 1:
    middle = (right + left) // 2
    if check(middle, n, m, k):
        left = middle
    else:
        right = middle
print(left)
print(check(3, n, m , k))

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     print(pillows)
     print(pilCount)
     print(left, right)
     if left <= 2 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 2 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

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

print((m//n)+1)

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

done = 0

for A in range(m // n,m+1):

	up = A

	if (k-1) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + k - A
	else:
		s = A - k + 1
		up = up + (s + (A - 1)) * (A - s) / 2

	kk = n - k

	if (kk-1) >= (A-1):
		up = up + A * (A-1) / 2
		up = up + kk - A
	else:
		s = A - kk
		up = up + (s + (A - 1)) * (A - s) / 2

	if up > m:
		done = 1
		print(A-1)
		break

if done == 0:

	print(m)

__author__ = 'zihaozhu'
from sys import stdin

hobbits, pillow, frodo = map(int,stdin.readline().split())

maxpossible = pillow- hobbits
"""
if maxpossible<=2:
    print(maxpossible)
elif hobbits == frodo and maxpossible-1<2:
    print(pillow)
elif frodo == 1 and maxpossible-1<2:
    print(pillow)

else:
"""
if frodo!=1 and frodo!=hobbits:
    n = 0
    """
    while ((n)*(n+1)/2)+((n)*(n+1)/2)<pillow:
        n+=1
    maxpossible -= 2*(n-1)
    print(1+maxpossible)
    """
    while (n*(n+1)/2)+(n*(n+1)/2)<pillow:
        n+=1
    n = n-1
    #print(n)
    #new = pillow - (hobbits-1)*(1+n)
    ans = pillow - (n*(n+1))-(n*(n+1))
    print(int(ans))
else:
    n=0
    #print(maxpossible)
    #3 6 1
    # 3 10 3 == 7  5
    #while (n*(n+1)/2) <=maxpossible-2:
    #    n+=1
    while (n*(n+1)/2)<pillow:
        n+=1

    n = n-1
    #print(n)
    #new = pillow - (hobbits-1)*(1+n)
    ans = pillow - (n*(n+1)/2)
    print(int(ans))
    #maxpossible -= (n-1)
    #print(1+maxpossible)

def main():
    n, m, k = map(int, raw_input().split())

    print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n

if __name__ == '__main__':
    main()

n, m, k = map(int, input().split())
f = lambda k, s: max((2 * s - k) * k, (s + 1) * s + 2 * (k - s)) - s
s, m = 2, 2 * m + 1
while f(k, s) + f(n - k, s) < m: s += 1
print(s - 1)

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y = (k * (k - 1)) // 2 + ((n - k)*(3*k - 3 - n)) // 2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        z = int(p ** (1/2))
        return z + l

if __name__ == "__main__":
    print(read_input())

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

def one_sided(slots, x):
    if slots >= x-1:
        return (slots - x + 1) + (x-1)* x // 2
    else:
        return slots * ( 2* x - slots -1 ) // 2

def pillows_used(x):
    left_slot = k -1
    right_slot = n-k
    return x + one_sided(left_slot, x) + one_sided(right_slot, x) <= m

def main():
    left = 1
    right = m
    mid = (left + right) // 2
    if left == right:
        return mid
    while left != right:
        if pillows_used(mid):
            left = mid + 1
        else:
            right = mid
        mid = (left + right) // 2
    return mid - 1

print(main())

import math

def read(type=int):
    return type(input())

def read_arr(type=int):
    return [type(token) for token in input().split()]

def foo_c(n, i):
    return i * (n - i + 1)

def triangle(k, i):
    a, b = 1, (i + 1) // 2
    while a < b:
        m = (a + b + 1) // 2
        c = foo_c(i, m)
        if c > k:
            b = m - 1
        else:
            a = m
    return a

def foo2(m, i):
    k = int(math.sqrt(2 * m))
    return k if k * (k - 1) <= 2 * m else k - 1

def runB():
    n, m, k = read_arr()
    ans = 1
    m -= n
    k = min(k, n + 1 - k)
    if k > 1:
        t = 2 * k - 3
        a = triangle(m, t)
        m -= foo_c(t, a)
        ans += a + (m // n)
        if m >= t + 2:
            ans += 1
            m -= (t + 2)
        ans += m // n
        print(ans)
    else:
        a = min(n, foo2(m, n))
        ans += a
        m -= (a * (a + 1)) // 2
        if m >= a + 1:
            ans += 1
            m -= a + 1
        ans += m // n
        print(ans)

runB()

import math

def read(type=int):
    return type(input())

def read_arr(type=int):
    return [type(token) for token in input().split()]

def foo_c(n, i):
    return i * (n - i + 1)

def triangle(k, i):
    a, b = 1, (i + 1) // 2
    while a < b:
        m = (a + b + 1) // 2
        c = foo_c(i, m)
        if c > k:
            b = m - 1
        else:
            a = m
    return a

def foo2(m, i):
    k = int(math.sqrt(2 * m))
    return k if k * (k - 1) <= 2 * m else k - 1

def runB():
    n, m, k = read_arr()
    ans = 1
    m -= n
    k = min(k, n + 1 - k)
    if k > 1:
        t = 2 * k - 3
        a = triangle(m, t)
        m -= foo_c(t, a)
        ans += a
        l = a + max(a-1, k-1)
        if m >= l:
            ans += 1
            m -= l
        ans += m // n
        print(ans)
    else:
        a = min(n, foo2(m, n))
        ans += a
        m -= (a * (a + 1)) // 2
        if m >= a + 1:
            ans += 1
            m -= a + 1
        ans += m // n
        print(ans)

runB()

def works(n, m, k, h):
    height = h
    pillows = h
    for i in range(k+1, n+1):
        height -= 1
        if height == 0: break
        pillows += height
    height = h
    for i in range(k-1, 0, -1):
        height -= 1
        if height == 0: break
        pillows += height
    return pillows <= m

n, m, k = map(int, raw_input().split())
hi = 1000000500
lo = 1
while lo + 1 < hi:
    mid = (lo + hi) / 2
    if works(n, m, k, mid):
        lo = mid
    else:
        hi = mid

print lo

import math,string,itertools,fractions,heapq,collections,re,array,bisect,random

# read input
n, m, k = map(int, input().split())

# n, m, k = 3, 10, 3

r = m - n

ans = 1

p = k - 1
q = n - k

# print(r, p, q)

def cost(i, p):
	c = max(p*i - p * (p+1)/2, 0)
	return int(c)

r0 = r
le = 0
ri = r0
if(r > 0):
	i = le
	while(abs(le - ri) > 1):
		c = i + cost(i, p) + cost(i, q)
		r0 = r - c
		# print(c, r0, le, ri)
		if(r0 >= 0):
			le = i
		else:
			ri = i
		i = (le + ri)//2

	c1 = ri + cost(ri, p) + cost(ri, q)
	r0 = r - c1
	if(r0 >= 0):
		ans += ri
	else:
		ans += le

	print(ans)
else:
	print(ans)

import math
n, m, k = map(int, input().split(' '))

div = (m/n)
mod = m%n

if mod == 0 or mod == 1:
    if div%2 == 0:
        print(math.ceil(div+1))
    else:
         print(math.ceil(div))
else:
    print(mod)

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

def get_min_pillow(bed,x):
    res = (x-1) *x /2
    if bed >x-1:
        res += bed -x + 1
    elif bed <x-1:
        temp =x-1 - bed
        res -= temp * (temp + 1)/2
    return res

def check(x):
    return (get_min_pillow(k-1,x) + x + get_min_pillow(n-k,x)) <= m

l = 1
r = m + 1
ans = 1

while r - l > 1:
    mid = (l + r) >> 1
    if check(mid):
        ans = mid
        l = mid
    else:
        r = mid
print(ans)

n, m, k = map(int,raw_input().split())
x = max(k,n-k+1)
x_min = min(k-1,n-k)
s_min = sum(range(x_min+1))
x_max = max(k-1,n-k)
s_max = sum(range(x_max+1))
o = m + s_min + s_max
x = (o-o%n)/n
pods = x*n - s_min - s_max
if(m>=n*x_max - s_min - s_max):
    print x
else:
    x = 1
    pods = n

    add = 0
    add_r = 0
    add_l = 0
    lim_l = 0
    for j in range(n):
        add_r = j
        if(j<=x_min):
            add_l += j
            if(j+1>x_min):
                lim_l = j
        else:
            add_l += lim_l
        add += 1 + add_r + add_l
        print add, add_l, add_r
        if(pods+add<=m):

            x += 1
        else:
            print pods,add-1-add_r-add_l
            print x
            break

# from itertools import combinations
# from bisect import bisect_right
# from functools import *
# from collections import Counter

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

def sumRange(l, r):
    if l > r:
        return 0
    return sum(r) - sum(l - 1)

I = lambda: list(map(int, input().split()))
n, m, k = I()
l, r = 1, m + 1
while l < r - 1:
    mid = (l + r) >> 1
    s = sumRange(mid - k + 1, mid) + sumRange(mid - n + k, mid - 1)
    if s <= m:
        l = mid
    else:
        r = mid
print(l)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
##     print(pillows)
##     print(pilCount)
##     print(left, right)
     if left <= 2 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 2 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

import math,string,itertools,fractions,heapq,collections,re,array,bisect,random

# read input
# n, m, k = map(int, input().split())

n, m, k = 10, 20, 5

r = m - n

ans = 1

p = k - 1
q = n - k

# print(r, p, q)

def cost(i, p):
	c = p*i - p * (p+1)/2
	return int(c)

r0 = r
le = 0
ri = r0
if(r > 0):
	i = le
	while(abs(le - ri) > 1):
		c = i + cost(i, p) + cost(i, q)
		r0 = r - c
		print(c, r0, le, ri)
		if(r0 == 0):
			break
		if(r0 > 0):
			le = i
		else:
			ri = i
		i = (le + ri)//2

	ans += le

	print(ans)
else:
	print(ans)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     left-=1
     right+=1
     if left <= 1 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 1 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break

     pilCount+=1
     turn+=1
print(pilCount)

numbers = map(int, raw_input().split())
n = numbers[0]
m = numbers[1]
k = numbers[2]

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

lo = 1
hi = m
if( hi - lo < 5 ):
	for i in range(hi, lo-1, -1):
		if k > i:
			left = sum(i-1) + k - i
		else:
			left = sum(i - 1) - sum( i - k)
		if n - k > i:
			right = sum( i -1) + n - k - i + 1
		else:
			right = sum( i - 1) - sum( i - (n-k) - 1 )
		print left," ",right," ",i," pillows required for ",i
		if( left + right + i <= m ):
			print i
			exit(0)
	print "Trouble"
	exit(1)
while lo < hi:
	if( hi - lo < 5 ):
		for i in range(hi, lo-1, -1):
			if k > i:
				left = sum(i-1) + k - i
			else:
				left = sum(i - 1) - sum( i - k)
			if n - k > i:
				right = sum( i -1) + n - k - i + 1
			else:
				right = sum( i - 1) - sum( i - (n-k) - 1 )
			print left," ",right," ",i," pillows required for ",i
			if( left + right + i <= m ):
				print i
				exit(0)
		print "Trouble"
		exit(1)
	mid = (lo + hi)/2
	# print lo, mid, hi
	if k > mid:
		left = sum(mid-1) + k - mid
	else:
		left = sum(mid - 1) - sum( mid - k)
	if n - k > mid:
		right = sum( mid -1) + n - k - mid + 1
	else:
		right = sum( mid - 1) - sum( mid - (n-k) - 1 )

	if left + right + mid <= m:
		lo = mid
	else:
		hi = mid - 1

def f(tar,n,m,k):
    p=0
    if k==1 or k==n:
        k=n
        p+=((tar*(tar+1))//2)
        p+=(max(0,n-tar))
        u=k-1
        v=tar-u-1
        a=(tar*(tar+1))//2
        b=(v*(v+1))//2
        p-=max(0,b)
    else:
        u=k-1
        v=tar-u-1
        a=(tar*(tar+1))//2
        b=(v*(v+1))//2
        p+=(a-b)
        p+=(max(0,k-tar))
        u=n-k
        v=tar-u-1
        c=(v*(v+1))//2
        p+=(a-c)
        d=k+tar-1
        e=n-d
        p+=(max(0,e))
        p-=tar
    if p<=m:
        return True
    else:
        return False

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

low,high,ans=m//n,10**18,m//n
while(low<=high):
    mid=low+(high-low)//2
    x=f(mid,n,m,k)
    if x:
        ans=max(ans,mid)
        low=mid+1
    else:
        high=mid-1

print(ans)

n, m, k = map(int,raw_input().split())
x = 1
pods = n
x_min = min(k-1,n-k)
x_max = max(k-1,n-k)
add = 0
add_r = 0
add_l = 0
lim_l = 0
for j in range(n):
    add_r = j
    if(j<=x_min):
        add_l += j
        if(j+1>x_min):
            lim_l = j
    else:
        add_l += lim_l
    add += 1 + add_r + add_l
        #print add,add_r,add_l
    if(pods+add<=m):
        x += 1
    else:
        print x
        break

def num(t):
    t = t - 1
    r = t * t + n
    r -= max(0, ((t - k) * (t - k + 1)) // 2)
    r -= max(0, ((t - (n - k + 1)) * (t - (n - k))) // 2)
    return r

s = input().split()

n = int(s[0])
m = int(s[1])
k = int(s[2])

lo = 1
hi = 10 ** 9 + 10

while lo < hi:
    #print("lo =", lo)
    #print("hi =", hi)
    mid = (lo + hi + 1) // 2
    #print("mid =", mid)
    #print("pillows =", num(mid))
    if num(mid) <= m:
        lo = mid
    else:
        hi = mid - 1

print(str(lo))

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y1 = (k * (k - 1)) // 2
    y2 = ((n - k)*(3*k - 3 - n)) // 2
    y = y1 + y2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        c = n - k
        z = 0
        if p != 0:
            while True:
                z1 = (z * (z + 1)) // 2
                z2 = min(max(((n - k) * (z - 1 + z + k - n)) // 2, 0), z1)
                if z1 + z2 > p:
                    break
                z += 1
            return z
        else:
            return z + 1

if __name__ == "__main__":
    print(read_input())

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y1 = (k * (k - 1)) // 2
    y2 = ((n - k)*(3*k - 3 - n)) // 2
    y = y1 + y2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        c = n - k
        z = int(p ** (1/2))
        while True:
            z1 = (z * (z + 1)) // 2
            z2 = ((n - k) * (z - 1 + z + k - n)) // 2
            if z1 + z2 > p:
                break
            z += 1
        return z

if __name__ == "__main__":
    print(read_input())

"""
http://codeforces.com/contest/760/problem/B
YYYYYYYYYYNNNNNNNNN

NNNNYYYYY : return left
YYYYYYNNN : return right
"""

n, m, k = map(int, raw_input().split())

def solve():

	lo = 0
	hi = m

	while (lo + 1 < hi):
		mid = (lo + hi) / 2

		if (check(mid)):
			lo = mid

		else:
			hi = mid

	return lo

def check(mid):

	idx1 = k - 1
	idx2 = k + 1

	num_pills = mid

	he_will_get1 = mid - 1
	while (idx1 > 0):
		if (he_will_get1 <= 0):
			he_will_get1 = 1
		num_pills += he_will_get1
		he_will_get1 -= 1
		idx1 -= 1

	he_will_get2 = mid - 1
	while (idx2 <= n):
		if (he_will_get2 <= 0):
			he_will_get2 = 1
		num_pills += he_will_get2
		he_will_get2 -= 1
		idx2 += 1
	# import pdb; pdb.set_trace()
	if (num_pills > m):
		return False
	return True

print solve()

r=list(map(int,input().split()))
n=r[0]
m=r[1]
k=r[2]

i=m%n
print(m//n+1)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs
while True:
     if left<= 1 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 1 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1
print(pilCount)

def read_input():
    line = input().strip().split()
    n = int(line[0])
    m = int(line[1])
    k = int(line[2])
    p = m - n
    k = max(n-k+1, k)
    y1 = (k * (k - 1)) // 2
    y2 = ((n - k)*(3*k - 3 - n)) // 2
    y = y1 + y2
    l = 1
    if p >= y:
        l += k - 1
        p -= y
        l += p//n
        return l
    else:
        c = n - k
        z = int(p ** (1/2))
        while z ** 2 < p:
            z1 = (z * (z + 1)) // 2
            z2 = ((n - k) * (z - 1 + z + k - n)) // 2
            if z1 + z2 > p:
                break
            z += 1
        return z + l

if __name__ == "__main__":
    print(read_input())

import math
def c(k,n):
    return (k-1)*(k-1)+(n-k*2+1)*(n-k*2)/2+(k*2-1)*(n-k*2+1)

n,m,k=list(map(int,input().split()))
m=m-n
if k>n/2:
    k=n-k+1

if k*k>=m:
    for i in range(k):
        if i*i>m:
            print(i)
            exit()
    print(i+1)
    exit()
elif c(k,n)>=m:
    m=m-(k-1)*(k-1)
    for i in range(n+5):
        if i*((i-1)/2+k*2)>m:
            print(i+k)
            exit()
else:
    m=m-c(k,n)
    print(m//n+n-k+1)

from random import random
import math
import re
import fractions

# N = input()
N, P, K = map(int, raw_input().split(" "))

l = K-1
r = N-K
P -= N
def test(x):
    return x * x <= P + max(0,x-l-1)*(x-l)/2 + max(0,x-r-1)*(x-r)/2
c = 0
il = 0
ir = P
while il < ir - 1:
    mid = (il + ir)/2
    if test(mid):
        il = mid
    else:
        ir = mid
print il+1

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     print(pillows)
     print(pilCount)
     print(left, right)
     if left < 1 and right > hobs:
          pilCount+=pillows//hobs
          break
     elif left < 1 or right > hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

n, m, k = map(int,raw_input().split())
x = 1
pods = n
x_min = min(k-1,n-k)
x_max = max(k-1,n-k)
add = 0
add_r = 0
add_l = 0
lim_l = 0
f=0
for j in range(n):
    add_r = j
    if(j<=x_min):
        add_l += j
        if(j+1>x_min):
            lim_l = j
    else:
        add_l += lim_l
    add += 1 + add_r + add_l
        #print add,add_r,add_l
    if(pods+add<=m):
        x += 1
    else:
        print x
        f = 1
        break
if(f==0):
    print x

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     if left <= 1 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 1 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1
print(pilCount)

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = sum_range(1, min(k - 1, m / n)), sum_range(1, min(n - k, m / n))
    print int((m + L + R) / n)

if __name__ == '__main__':
    main()

n, m, k = map(int, raw_input().split(' '))
m -= n
l, r = k - 1, n - k
d = 1
for idx in xrange(int(1e9)):
    if idx < l or idx < r:
        if idx < l:
            d += 1
        if idx < r:
            d += 1
        m -= d
        if m == 0:
            print idx + 1
            break
        if m < 0:
            print idx + 2
            break
    else:
        if m % d == 0:
            print idx + 1 + m / d
        else:
            print idx + 2 + m / d
        break

def works(n, m, k, h):
    height = h
    pillows = h
    for i in range(k+1, n+1):
        height -= 1
        if height == 0: break
        pillows += height
    height = h
    for i in range(k-1, 0, -1):
        height -= 1
        if height == 0: break
        pillows += height
    return pillows <= m

n, m, k = map(int, raw_input().split())
hi = 1000000500
lo = 1
while lo + 1 < hi:
    mid = (lo + hi) / 2
    if works(n, m, k, mid):
        lo = mid
    else:
        hi = mid

print lo

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = 0, m
    while L + 1 < R:
        x = L + (R - L) / 2
        l, r = x - (k - 1), x - (n - k)
        sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)
        if l < 1:
            sl += 1 - l
        if r < 1:
            sr += 1 - r
        if sl + sr - x <= m:
            L = x
        else:
            R = x
    print max(L, 1)

if __name__ == '__main__':
    main()

n, m, k = map(int, input().split())
m -= n
soon = False
summ = 0
g = 1
for i in range(1, 1 + min(n-k+1, k)):
    summ += g
    g += 2
    if summ + g > m:
        soon = True
        break
g -= 1
if not soon:
    for i in range(1 + min(n-k+1, k), 1 + max(n-k+1, k)):
        summ += g
        g += 1
        if summ + g > m:
            soon = True
            break
print(summ, soon)
print(i)
print(1 + i if soon else 1 + i + (m - summ) // n)

import math,string,itertools,fractions,heapq,collections,re,array,bisect,random

# read input
n, m, k = map(int, input().split())

# n, m, k = 3, 10, 3

r = m - n

ans = 1

p = k - 1
q = n - k

# print(r, p, q)

def cost(i, p):
	c = p*i - p * (p+1)/2
	return int(c)

r0 = r
le = 0
ri = r0
if(r > 0):
	i = le
	while(abs(le - ri) > 1):
		c = i + cost(i, p) + cost(i, q)
		r0 = r - c
		# print(c, r0, le, ri)
		if(r0 >= 0):
			le = i
		else:
			ri = i
		i = (le + ri)//2

	c1 = ri + cost(ri, p) + cost(ri, q)
	r0 = r - c1
	if(r0 >= 0):
		ans += ri
	else:
		ans += le

	print(ans)
else:
	print(ans)

n, m, k = map(int, input().split())
k -= 1

res = 0
r = 0
while True:

  a = r - k
  u = 0
  if a > 0:
    u += (a + r) * (k + 1) // 2
  else:
    u += r * (r + 1) // 2

  b = r - (n - 1 - k)
  v = 0
  if b > 0:
    v += (b + r) * (n - k) // 2
  else:
    v += r * (r + 1) // 2

  t = u + v - r
  if t <= m:
    res = r
  if t > m :
    break
  r += 1

print(res)

#-*- coding:utf-8 -*-
#/usr/bin/python3

n, m, kk = map(int, input().split())

def getleft(x, k):
	res = 0
	if x < k:
		res = (1 + x) * x / 2
		x = k - x
		res += x // 2 * 3
		if x % 2 == 1:
			res += 2
	else:
		res = (x - k + 1 + x) * k / 2
	return res

def getright(x, k):
	return getleft(x, n - k + 1)

lt = 1
rt = m
ans = 1

while lt <= rt:
	mid = (lt + rt) // 2
	#print(lt, rt, mid)
	ta = getleft(mid, kk) + getright(mid, kk) - mid
	if ta <= m:
		lt = mid + 1; ans = mid
	else:
		rt = mid - 1

print(ans)

#!/usr/bin/env python3
def ri():
    return map(int, input().split())

n, m, k = ri()
m -= n
ans = 1
cnt = 1
if k + ans >= n and k - ans <= 1:
    if m > 0:
        ans += m//n
    print(ans)
    exit()
while m > 0:
    ans += 1
    if k + ans >= n and k - ans <= 1:
        break
    if k + ans <= n:
        cnt += 1
    if k - ans >= 1:
        cnt += 1
    m -= cnt

if m > 0:
    ans += m//n
print(ans)

numbers = map(int, raw_input().split())
n = numbers[0]
m = numbers[1]
k = numbers[2]

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

lo = 1
hi = m
while lo < hi:
	if( hi - lo < 5 ):
		for i in range(hi, lo-1, -1):
			if k > i:
				left = sum(i-1) + k - i
			else:
				left = sum(i - 1) - sum( i - k)
			if n - k > i:
				right = sum( i -1) + n - k - i
			else:
				right = sum( i - 1) - sum( i - (n-k) - 1 )
			# print left," ",right," ",i," pillows required for ",i
			if( left + right + i <= m ):
				print i
				exit(0)
		print "Trouble"
		exit(1)
	mid = (lo + hi)/2
	# print lo, mid, hi
	if k > mid:
		left = sum(mid-1) + k - mid
	else:
		left = sum(mid - 1) - sum( mid - k)
	if n - k > mid:
		right = sum( mid -1) + n - k - mid
	else:
		right = sum( mid - 1) - sum( mid - (n-k) - 1 )

	if left + right + mid <= m:
		lo = mid
	else:
		hi = mid - 1

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

def valid(x):
    a = min(k - 1, x - 1)
    b = min(n - k, x - 1)
    s1 = a * (x - 1 + x - a) // 2
    s2 = b * (x - 1 + x - b) // 2
    return s1 + s2 + x <= m

l, r = -1, (1<<62)
while r > l+1:
    m = l + r >> 1
    if valid(m):
        l = m
    else:
        r = m
print(l+1)

hobbits_nr, pillows_nr, frodos_place = (int(x) for x in input().split())

pillows_nr = pillows_nr - hobbits_nr
frodos_pillows = 1

# [left, right) -- it's a half-interval
left = frodos_place
right = frodos_place + 1

while pillows_nr >= right - left:
    pillows_nr -= right - left
    frodos_pillows += 1
    right += 1
    left += -1
    if right > hobbits_nr + 1:
        right = hobbits_nr + 1
    if left < 1:
        left = 1
print(pillows_nr)
print(left, right)
print(frodos_pillows)

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = 0, m
    while L + 1 < R:
        x = L + (R - L) / 2
        l, r = x - (k - 1), x - (n - k)
        sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)
        if l < 1:
            sl += 1 - l
        if r < 1:
            sr += 1 - r
        if sl + sr - x <= m:
            L = x
        else:
            R = x
    print L

if __name__ == '__main__':
    main()

from math import ceil

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

def check(middle, n, m, k):
    if k != 1 and k != n:
        return middle - ((m - middle) // (n - 1)) < 2
    return middle - ceil((m - middle) / (n - 1)) < 2

left = 0
right = m
while right - left > 1:
    middle = (right + left) // 2
    if check(middle, n, m, k):
        left = middle
    else:
        right = middle
print(left)
#print(check(3, n, m , k))

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     if left <= 2 and right >= hobs-1:
          pilCount+=pillows//hobs
          break
     elif left <= 2 or right >= hobs-1:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break
     left-=1
     right+=1
     pilCount+=1
     turn+=1

print(pilCount)

#!/usr/bin/env python

def sum_range(l, r):
    return (l + r) * (r - l + 1) / 2

def main():
    n, m, k = map(int, raw_input().split(' '))
    L, R = sum_range(1, min(k - 1, m / n)), sum_range(1, min(n - k, m / n))
    print int((m + L + R) / n)

if __name__ == '__main__':
    main()

a = [int(i) for i in raw_input().split()]
k=a[2]
n=a[0]
m=a[1]
l=k-1
r=n-k
m-=n
p=1
ans=2
if m==0:
    print 1
elif m==1:
    print 2

else:
    m-=1
    while m>0:
        if l>0:
            p+=1
            l-=1
        if r>0:
            p+=1
            r-=1
        m-=p
        if m<0:
            break
        ans+=1
print ans

import math
n, m, k = map(int, input().split(' '))

div = (m/n)
mod = m%n

if mod == 0 or mod == 1:
    if div%2 == 0:
        print(math.ceil(div+1))
    else:
         print(math.ceil(div))
else:
    print(mod)

hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows-=hobs

while True:
     left-=1
     right+=1
     if left <= 1 and right >= hobs:
          pilCount+=pillows//hobs
          break
     elif left <= 1 or right >= hobs:
          pillows-=(turn+1)
     else:
          pillows-=(turn*2+1)

     if pillows < 0:
          break

     pilCount+=1
     turn+=1
print(pilCount)

from math import *
n,m,k=map(int,input().split())
r,l=0,0

if k!=n:
    r=n-k
if k!=1:
    l=k-1
if l>r:
    S=((1+l)*(l)//2)+((l+n)*r//2)
else:
    S=((1+r)*(r)//2)+((r+n)*l//2)
S+=k
s=max(l,r)+1
L,R=max(l,r),min(l,r)
if L!=R:
    B=False
    L-=1
else:
    L-=1
    R-=1
    B=True
i=0
while S>m:
    s=s-1
    S-=l+r
    if L==0 :
        s-=1
        S-=n-2*i
        i+=1
    if L>0:
        L-=1
    if B:
        R-=1
    elif L==R:
        B=True

if S!=m and (m-S)//n!=0:
    s+=(m-S)//n
print(s)