qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
x=int(input())
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in range(x,10**5):
  if is_prime(i)==True:
    print(i)
    exit()
  

# Fixed code:
x=int(input())
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in range(x,10**6):
  if is_prime(i)==True:
    print(i)
    exit()
# Buggy code:
X = int(input())

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

def main():
  if is_prime(X) == True:
    print(X)
  else:
    return is_prime(X+1)

if __name__ == '__main__':
  main()

# Fixed code:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main(X):
  if is_prime(X) == True:
    print(X)
  else:
    return main(X+1)

if __name__ == '__main__':
  X = int(input())
  main(X)
# Buggy code:
n=int(input())
if n==2:
    print(n)
else:
    cost=0
    for i in range(n,10**6):
        for j in range(2,int(i**0.5))+1):
            if i%j==0:
                cost+=1
        if cost==0:
            print(i)
            break

# Fixed code:
n=int(input())
for i in range(n,10**6):
  for j in range(2,int(i**0.5)+1):
    if i%j==0:
      break
  else:
    print(i)
    break
# Buggy code:
isprime = [True] * 20001

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

		
def program():
  x = int(input())
  N = 10100
  prime = seive(N) 
    
  for i in range(len(prime)):
    if prime[i] >= x:
      return prime[i]
      break
		
print(program())


# Fixed code:
isprime = [True] * 100201

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

		
def program():
  x = int(input())
  N = 100200
  prime = seive(N) 
    
  for i in range(len(prime)):
    if prime[i] >= x:
      return prime[i]
      break
		
print(program())
# Buggy code:
X = int(input())
i = int(n**0.5)

while i >= 2:
    if X % i == 0:
        X += 1
        i = int(X**0.5)
    else:
        i -= 1
        
print(X)

# Fixed code:
X = int(input())
i = int(X**0.5)

while i >= 2:
    if X % i == 0:
        X += 1
        i = int(X**0.5)
    else:
        i -= 1
        
print(X)
# Buggy code:
import math
X = int(input())
for i in range(X,10**6):
    flag = True
    for j in range(2,int(i**0.5+1)):
        if (i%j) == 0:
            flag = False
            print('F',i,j)
            break
    if flag:
        print(i)
        exit()

# Fixed code:
import math
X = int(input())
for i in range(X,10**6):
    flag = True
    for j in range(2,int(i**0.5+1)):
        if (i%j) == 0:
            flag = False
            
            break
    if flag:
        print(i)
        exit()
# Buggy code:
import math
 
x = int(input())
f = True
if x == 2:
    print(2)
    exit()
 
while True:
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

# Fixed code:
import math
 
x = int(input())

if x == 2:
    print(2)
    exit()
 
while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1
# Buggy code:
X = int(input())

while True:
    for i in range(2, X):
        if X % i == 0:
            print(i)
            break
    else:
        break
    X += 1

print(X)

# Fixed code:
X = int(input())

while True:
    for i in range(2, X):
        if X % i == 0:
            break
    else:
        break
    X += 1

print(X)
# Buggy code:
X=int(input())
n = 200000
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
for i in range(len(primes)-1):
    if X==2:
        print("2")
    elif (primes[i]<X)and(X<=primes[i+1]):
        print(primes[i+1])

# Fixed code:
X=int(input())
n = 200000
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
for i in range(len(primes)-1):
    if X==2:
        print("2")
        break
    elif (primes[i]<X)and(X<=primes[i+1]):
        print(primes[i+1])
        break
# Buggy code:
import numpy as np
x=int(input())
a = 0
b = 0
while b == 0:
    s = int(np.sqrt(x))
    print(s,x)
    for i in range(s):
        if x % (i+2) == 0:
            a = 1
            x += 1
            break
    print(a)
    if a == 0:
        b = 1
    else:
        a = 0
print(x)

# Fixed code:
import numpy as np
x=int(input())
a = 0
b = 0
if x > 2:
    while b == 0:
        s = int(np.sqrt(x))
        for i in range(s):
            if x % (i+2) == 0:
                a = 1
                x += 1
                break
        if a == 0:
            b = 1
        else:
            a = 0
print(x)
# Buggy code:
import sys
input=sys.stdin.readline
import math
X = int(input())
if X == 2:
    print(2)
x = math.ceil(math.sqrt(X))
for i in range(X,X+1000):
    c = 0
    for j in range(2,x+1):
        if i % j == 0:
            c = 1
            break
    if c == 0:
        print(i)
        break

# Fixed code:
import sys
input=sys.stdin.readline
import math
X = int(input())
if X == 2:
    print(2)
else:
  x = math.ceil(math.sqrt(X))
  for i in range(X,X+1000):
      c = 0
      for j in range(2,x+1):
          if i % j == 0:
              c = 1
              break
      if c == 0:
          print(i)
          break
# Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x=int(readline())
def a(n):
  for i in range(2, int(n ** 0.5 + 1)):
    if n % i == 0:
      return False
  return True
  
  
n=x+1
while True:
  if a(n):
    pint(n)
    quit()
  n+=1

# Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x=int(readline())
def a(n):
  for i in range(2, int(n ** 0.5 + 1)):
    if n % i == 0:
      return False
  return True
  

while True:
  if a(x):
    print(x)
    quit()
  x+=1
# Buggy code:
import sys

def f(i):
    if v<=p+n-2-i: return 1
    elif a[i]+m<a[p-1]: return 0
    able=(p+n-2-i)*m
    able+=sum([a[i]+m-a[k] for k in range(p-1,i)])
    if able>=m*v: return 1
    else: return 0

n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)

print(a)
print([f(i) for i in range(n)])
l,r=0,n-1
if f(r)==1: print(n);sys.exit()
while r-l>1:
    tmp=(l+r)//2
    if f(tmp)==1: l=tmp
    else: r=tmp
print(r)


# Fixed code:
import sys

def f(x):
    if a[x]+m<a[p-1]: return 0
    elif v<=p+n-1-x: return 1
    able=(p+n-1-x)*m
    able+=sum([a[x]+m-a[k] for k in range(p-1,x)])
    if able>=m*v: return 1
    else: return 0

n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)

l,r=0,n-1
if f(r)==1: print(n);sys.exit()
while r-l>0:
    if r-l==1 and f(l)==1 and f(r)==0: break
    tmp=(l+r)//2
    if f(tmp)==1: l=tmp
    else: r=tmp
print(l+1)
# Buggy code:
from itertools import *
n, m, v, p, *a = map(int, open(0).read().split())
a.sort(reverse=True)
acc = list(accumulate(a)) + [0]
ok, ng = p - 1, n
while ng - ok > 1:
	mid = (ok + ng) // 2
	if a[mid] + m > a[p - 1] and (a[mid] + m) * (mid - p + 1) - (acc[mid - 1] - acc[p - 2]) >= m * (
			v - (p - 1) - (n - mid)):
		ok = mid
	else:
		ng = mid
print(ok + 1)

# Fixed code:
from itertools import *
n,m,v,p,*a=map(int,open(0).read().split())
a.sort(reverse=True)
acc=list(accumulate(a))+[0]
ok,ng=p-1,n
while ng-ok>1:
	mid=(ok+ng)//2
	if a[mid]+m>=a[p-1] and (a[mid]+m)*(mid-p+1)-(acc[mid-1]-acc[p-2])>=m*(v-(p-1)-(n-mid)):
		ok=mid
	else:
		ng=mid
print(ok+1)
# Buggy code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,v,p = LI()
    a = LI()
    a.sort()
    l = -1
    r = n-1
    print(a)
    while l+1 < r:
        i = (l+r) >> 1
        A = a[i]+m
        ri = bisect.bisect_right(a,A)
        j = n-ri
        if j >= p:
            l = i
            continue
        li = bisect.bisect_right(a,a[i])
        res = v-j-li
        if res <= 0:
            r = i
            continue
        res -= (p-j-1)
        s = 0
        for j in range(li,ri-(p-j-1)):
            s += A-a[j]
        if s >= res*m:
            r = i
        else:
            l = i
    print(n-r)
    return

#Solve
if __name__ == "__main__":
    solve()


# Fixed code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,v,p = LI()
    a = LI()
    a.sort()
    l = -1
    r = n-1
    while l+1 < r:
        i = (l+r) >> 1
        A = a[i]+m
        ri = bisect.bisect_right(a,A)
        j = n-ri
        if j >= p:
            l = i
            continue
        s = m
        for j in range(n-p+1):
            if i == j:
                continue
            s += min(m,A-a[j])
        s += m*(p-1)
        if s >= m*v:
            r = i
        else:
            l = i
    print(n-r)
    return

#Solve
if __name__ == "__main__":
    solve()
# Buggy code:
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[p-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > v):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,p-1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)

# Fixed code:
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[i-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > m):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,i-p+1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)
# Buggy code:
def check_pickedup(M: int, V: int, P: int, A: list, accum_score: list, i: int) -> bool:
    th_score = A[P-1]
    if A[i] >= th_score:
        return True
    sum_surplus = accum_score[i-1] - accum_score[P-2]
    if th_score - A[i] <= M and sum_surplus <= M*V:
        return True
    return False

def main():
    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    
    A.sort(reverse=True)
    
    accum_score = [A[0]] * N
    for i in (1, N):
        accum_score[i] = accum_score[i-1] + A[i]
    
    # Reduce N-V scores each judge
    ans = 0
    was_checked = {}
    for i, a in enumerate(A):
        # Check a will be picked up
        if a in was_checked:
            ans += 1
            continue
        if check_pickedup(M, V, P, A, accum_score, i):
            ans += 1
            was_checked[a] = True
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()


# Fixed code:
def check_pickedup(N: int, M: int, V: int, P: int, A: list, accum_score: list, i: int) -> bool:
    th_score = A[P-1]
    if A[i] >= th_score:
        return True
    sum_surplus = (accum_score[i-1] - (accum_score[P-2] if P-2 >=0 else 0)) - ((i-1)-(P-2))*A[i]
    #print('i: ', i)
    #print('th_score: ', th_score)
    #print('sum_surplus: ', sum_surplus)
    #print('th_score - A[i]: ', th_score - A[i])
    if th_score - A[i] <= M and sum_surplus <= M*(N-V):
        return True
    return False

def main():
    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    
    A.sort(reverse=True)
    
    accum_score = [A[0]] * N
    for i in range(1, N):
        accum_score[i] = accum_score[i-1] + A[i]
    
    # Reduce N-V scores each judge
    ans = 0
    was_checked = {}
    for i, a in enumerate(A):
        # Check a will be picked up
        if a in was_checked:
            ans += 1
            continue
        if check_pickedup(N, M, V, P, A, accum_score, i):
            ans += 1
            was_checked[a] = True
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()
# Buggy code:
n,m,v,p=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=p
S=[A[p-1]]
for i in range(p,n):
    S.append(S[-1]+A[i])
for i in range(p,n):
    if v<=p+n-i-1:
        if A[i]-A[p-1]<=m:
            ans+=1
    else:
        if A[i]-A[p-1]<=m and S[i-p]-A[i]*(i-p+1)<=(n-v)*m:
            ans+=1
        else:
            break
print(ans)

# Fixed code:
n,m,v,p=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=p
S=[A[p-1]]
for i in range(p,n):
    S.append(S[-1]+A[i])
for i in range(p,n):
    if v<=p+n-i-1:
        if A[p-1]-A[i]<=m:
            ans+=1
    else:
        if A[p-1]-A[i]<=m and S[i-p]-A[i]*(i-p+1)<=(n-v)*m:
            ans+=1
        else:
            break
print(ans)
# Buggy code:
from bisect import bisect_right as br
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))
l,r=n,0
while l-r>1:
    t=(l+r)//2
    s=a[t]+m
    w=a[:]
    k=m*v
    for i in range(n-1):
        if i!=t:
            if s>=w[i]:
                r=min(s-w[i],m)
                k-=r
                w[i]+=r
            if k==0:
                break
    if k>=0:
        for j in range(n-1,-1,-1):
            if j!=t:
                w[j]+=min(k,m-w[j]+a[j])
                k-=min(k,m-w[j]+a[j])
            if k==0:
                break
    if n-br(w,s)<=p:
        l=t
    else:
        r=t
print(n-r+1)

# Fixed code:
from bisect import bisect_right as br
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))
l,r=n,-1
while l-r>1:
    t=(l+r)//2
    s=a[t]+m
    w=a[:]
    k=m*(v-1)
    for i in range(n):
        if i!=t:
            if i<t:
                c=min(k,m)
                k-=c
                w[i]+=c
            else:
                if w[i]>=s:
                    break
                else:
                    c=min(k,s-w[i])
                    k-=c
                    w[i]+=c
        if k==0:
            break
    if k>0:
        for j in range(n-1,-1,-1):
            if j!=t:
                g=min(k,m-w[j]+a[j])
                w[j]+=g
                k-=g
            if k==0:
                break
    w.pop(t)
    w=sorted(w)
    if n-br(w,s)<=p:
        l=t
    else:
        r=t
print(n-l)
# Buggy code:
import sys
from bisect import bisect

def solve():
    input = sys.stdin.readline
    N, M, V, P = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    border = A[N - P]

    low, high = 0, N
    while high - low > 1:
        mid = (low + high) //2
        point = A[mid] + M
        if point < border: low = mid
        elif mid >= N - P: high = mid
        else:
            space = (mid + P) * M
            for i in range(mid + 1, N - P + 1): space -= point - A[i]
            if space >= M * V: high = mid
            else: low = mid
    print(N - low - 1)
    return 0

if __name__ == "__main__":
    solve()

# Fixed code:
import sys
from bisect import bisect

def solve():
    input = sys.stdin.readline
    N, M, V, P = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    border = A[N - P]

    low, high = -1, N
    while high - low > 1:
        mid = (low + high) //2
        point = A[mid] + M
        if point < border: low = mid
        elif mid >= N - P: high = mid
        else:
            space = (mid + P) * M
            for i in range(mid + 1, N - P + 1 ): space += point - A[i]
            if space >= M * V: high = mid
            else: low = mid
    print(N - low - 1)
    return 0

if __name__ == "__main__":
    solve()
# Buggy code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, V, P = mapint()
As = list(mapint())
As.sort(reverse=True)

threshold = As[P-1]
l, r = P, N
while l+1<r:
    half = (l+r)//2
    a = As[half]+M
    if a<threshold:
        r = half
    else:
        rest_sum = 0
        for i in range(P-1, N):
            if As[i]>=a:
                continue
            rest_sum += min(M, a-As[i])
        if M*V > rest_sum+P*M:
            r = half
        else:
            l = half
print(l+1)

# Fixed code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, V, P = mapint()
As = list(mapint())
As.sort(reverse=True)

threshold = As[P-1]
l, r = P-1, N
while l+1<r:
    half = (l+r)//2
    a = As[half]+M
    if a<threshold:
        r = half
    else:
        rest_sum = 0
        for i in range(P-1, N):
            if As[i]>=a:
                continue
            if i==half:
                continue
            rest_sum += min(M, a-As[i])
        if M*V > rest_sum+P*M:
            r = half
        else:
            l = half
print(l+1)
# Buggy code:
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
ans = p
border = a[p]
to_border = 0
for i in range(p,n):
    new_border = a[i] + m
    if new_border < border:
        print(ans)
        exit()
    possible_votes = 0
    possible_votes += (p+n-i-1)*m
    possible_votes += to_border
    possible_votes += (new_border-border)*(i-p)
    print((i,possible_votes))
    if possible_votes >= m*v:
        ans += 1
        to_border += border-a[i]
    else:
        print(ans)
        exit()
print(ans)
exit()

# Fixed code:
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
ans = p
border = a[p-1]
to_border = 0
for i in range(p,n):
    new_border = a[i] + m
    if new_border < border:
        print(ans)
        exit()
    possible_votes = 0
    possible_votes += (n+p-i-1)*m
    possible_votes += to_border
    possible_votes += (new_border-border)*(i-p+1)
    if possible_votes >= m*v:
        ans += 1
        to_border += border-a[i]
    else:
        print(ans)
        exit()
print(ans)
exit()
# Buggy code:
def check(n):
    """
    if n <= P-1:
        return True
    """

    if A[n]+M < A[P-1]:
        return False
    
    votes = (P+N-1-n)*M + sum([A[n]+M-A[i] for i in range(P-1,n)])

    if votes < M*V:
        return False
    else:
        return True

N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

right = N
left = P


##
"""
if check(right):
    print(N)
    exit()
"""
while abs(right-left) > 1:

    mid = (right+left)//2
    print(mid)

    if check(mid):
        left = mid
    else:
        right = mid

print(left+1)

# Fixed code:
def check(n):

    if n <= P-1:
        return True
    
    if A[n]+M < A[P-1]:
        return False
    
    votes = (P+N-1-n)*M + sum([A[n]+M-A[i] for i in range(P-1,n)])

    if votes < M*V:
        return False
    else:
        return True

N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

right = N-1
left = 0

if check(right):
    print(N)
    exit()

while abs(right-left) > 1 and check(left) and not check(right):

    mid = (right+left)//2

    if check(mid):
        left = mid
    else:
        right = mid

print(left+1)
# Buggy code:
def main():
    n, m, v, p = list(map(int, input().split()))
    a = sorted(list(map(int, input().split())))
    # print(a)

    def value(i):
        if i+p >= n:
            return True
        if a[n-p] > a[i]+m:
            return False
        b = list(reversed([a[i]+m-j for j in a[:i] + a[i+1:n]]))[p-2:]
        # print(b)
        if b[0] < 0:
            return False
        rest = v-n+len(b)
        if rest <= 0:
            return False
        # print(rest)

        c = [min(m, i) for i in b]
        d = [i for i in c][:-rest]
        e = [m-i for i in c][-rest:]
        #print(d, e)
        if sum(d) < sum(e):
            return False
        else:
            return True

    def b_search(a, b, value):
        while a+1 < b:
            med = (a+b)//2
            if value(med):
                b = med
            else:
                a = med+1
        if a == b:
            return a
        else:
            if value(a):
                return a
            else:
                return b

    # print(value(2))

    print(n-b_search(0, n-1, value))


main()


# Fixed code:
def main():
    n, m, v, p = list(map(int, input().split()))
    a = sorted(list(map(int, input().split())))
    # print(a)

    def value(i):
        if i+p >= n:
            return True
        if a[n-p] > a[i]+m:
            return False
        b = list(reversed([a[i]+m-j for j in a[:i] + a[i+1:n]]))[p-1:]
        #print(b)
        if b[0] < 0:
            return False
        rest = v-n+len(b)
        if rest <= 0:
            return True
        #print(rest)

        c = [min(m, i) for i in b]
        d = [i for i in c][:-rest]
        e = [m-i for i in c][-rest:]
        #print(d, e)
        if sum(d) < sum(e):
            return False
        else:
            return True

    def b_search(a, b, value):
        while a+1 < b:
            med = (a+b)//2
            if value(med):
                b = med
            else:
                a = med+1
        if a == b:
            return a
        else:
            if value(a):
                return a
            else:
                return b

    #print(value(1))

    print(n-b_search(0, n-1, value))


main()