Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from math import ceil,floor
import sys
input = sys.stdin.readline

N,M,V,P = map(int, input().split())
a = list(map(int, input().split()))
A = sorted(a)[::-1]
            
ans =P
for i in range(P,N):
    b = (V-((P-1)+(N-i)))
    target = A[i]+M
        
    if b<=0:
        if A[P-1]<=target:
            ans+=1
    else:
        if target<A[P-1]:
            break
        Q = A[P-1:i]
        
        Q_sum=sum(Q)
        len_Q=len(Q)
        if target*len_Q-Q_sum>=b*M:
            ans+=1
        else:
            break
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M,V,P = map(int, input().split())
a = list(map(int, input().split()))
A = sorted(a)[::-1]
           
right = P-1
left = N

while left - right !=1:
    
    i = (left+right)//2
    b = (V-((P-1)+(N-i)))
    target = A[i]+M

        
    if b<0:
        if A[P-1]<=target:
            right = i
        else:
            left = i
    else:
        if target<A[P-1]:
            left = i
        else:
            Q_sum=sum(A[P-1:i])
            len_Q =i-(P-1)
            if target*len_Q-Q_sum>=b*M:
                right = i
            else:
                left =i


print(right+1)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

lr = [list(map(int, input().split())) for _ in range(Q)]

for i in range(Q):
    w = S[lr[i][0]-1:lr[i][1]]
    print(w.count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 8)
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

cnt = [0 for i in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x

def dfs(frm, cur):
    if cur > 0:
        cnt[cur] += cnt[frm]
    for to in edges[cur]:
        if frm != to:
            dfs(cur, to)

dfs(-1, 0)
print(*cnt)

### FIXED CODE ###

#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)
### BUGGY CODE ###

from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

for i in range(len(A_s)):
  A_count.append(A.count(A_s[i]))


for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2




for i in range(N):
  if A_count[A_s.index(A[i])]==1:
    print(cnt)
  else:
    print(cnt-A_count[A_s.index(A[i])]+1)


 










### FIXED CODE ###

import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)
### BUGGY CODE ###

import re
N, Q = map(int, input().split())
S = input()
lr = list()
for _ in range(Q):
    lr.append(tuple(map(int, input().split())))
    
for i in lr:
    print(len(re.findall("AC", S[i[0]-1:i[1]])))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

acl = [0]*(N+1)

for i in range(N):
    acl[i+1] = acl[i] + (1 if S[i:i+2] == "AC" else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(acl[r-1] - acl[l-1])
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))

c = 0
for i in range(N-1):
  for j in range(i+1,N):
    if a[i] == j+1 and a[j] == i+1:
      c += 1
print(c)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))

c = 0
for i in range(N):
  if a[a[i]-1]-1 == i:
    c += 1
print(c//2)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(20000*20000)

S = str(input())
ans = set()

def dfs(i, j):
    if int(S[i:j+1])%2019 == 0:
        ans.add((i, j))
    if j == len(S)-1:
        return

    dfs(i, j+1)

if len(S) < 4:
    print(0)

else:
    for i in range(len(S)-3):
        dfs(i, i+3)
    print(len(ans))

### FIXED CODE ###

s=input()
n=len(s)
mod=2019
d=0
p=1
ml=[0]*mod
for i in range(1,n+1):
  k=int(s[-i])
  d+=p*k
  d%=mod
  ml[d]+=1
  p*=10
  p%=mod
ans=0
for i in ml:
  ans+=i*(i-1)//2
print(ans+ml[0])
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = {}
for i in range(N):
    routes[i] = []
for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = np.array([[mod,mod,mod] for i in range(N)])

# print(routes)
# def skip(now,move_cnt):
#     flag = True
#     if used[now] != mod:
#         if used[now] % 3 == 0 and move_cnt > used[now]:
#             flag = False
#     if used[now] > move_cnt:
#         if used[now] % 3 == 0 and move_cnt % 3 != 0:
#             pass
#         else:
#             used[now] = move_cnt
#     if flag:
#         for route in routes[now]:
#             skip(route,move_cnt+1)
def move2next(now,move_cnt):
    state = move_cnt % 3
    if used[now, state] <= move_cnt:
        flag = False # この条件だと前より遅いので探索ストップ
    else:
        used[now, state] = move_cnt
        for route in routes[now]:
            move2next(route, move_cnt+1)

move2next(S,0)
# print(used)
try:
    ans = used[T, 0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]

for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

from collections import deque

# q = queue.Queue()
q = deque()
q.append((S,0))
# Deep First Serch
while q:
    now, cost = q.popleft()
    for route in routes[now]:
        n_state = (cost + 1) % 3
        if used[route][n_state] == mod:
            used[route][n_state] = cost + 1
            q.append((route,cost+1))


# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))
### BUGGY CODE ###

from math import gcd

def prime_factorize(n):
    a = set()
    while n%2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f**2 <= n:
        if n%f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

n = int(input())
a = list(map(int, input().split()))
c0 = False
vals = []
for i, j in enumerate(a):
    vals += prime_factorize(j)
    if len(vals) != len(set(vals)) and c0 is False:
        c0 = True
        
if c0 is False:
    print('pairwise coprime')
else:
    b = gcd(a[0], a[1])
    for i in range(2, n):
        b = gcd(b, a[i])
    if b == 1:
        print('setwise coprime')
    else:
        print('not coprime')

        


### FIXED CODE ###

import sys
from math import gcd

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

b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(b, a[i])
if b != 1:
    print('not coprime')
else:
    c = set()
    num = max(a)
    m = 1000000
    vals = [0]*(m+1)

    for i in range(2, m):
        if vals[i] != 0:
            continue
        j = 1
        while True:
            t = i*j
            if t > m:
                break
            if vals[t] == 0:
                vals[t] = i
            j += 1
    d = dict()
    for i in a:
        p = i
        while p != 1:
            if p in d:
                print("setwise coprime")
                sys.exit()
            d[p] = 1
            p = int(p/vals[p])
    print("pairwise coprime")
### BUGGY CODE ###

n = int(input())
s = list(input())
for i in range(0,n-1):
    if s[i] == s[i+1]:
        s[i] = "0"
while "0" in s:
    s.remove("0")
print(len(s))


### FIXED CODE ###

n = int(input())
s = list(input())
x = n
for i in range(0,n-1):
    if s[i] == s[i+1]:
        s[i] = "0"
        x -= 1
print(x)
### BUGGY CODE ###

import numpy as np
N,M = (int(x) for x in input().split())
Now = np.zeros((N),dtype=int)
for T in range(0,M):
    L,R = (int(x) for x in input().split())
    Now[L-1:R] += 1
print(sum(Now==M))

### FIXED CODE ###

N,M = (int(x) for x in input().split())
Now = [0]*N
maxL = 1
minR = N
for T in range(0,M):
    L,R = (int(x) for x in input().split())
    if maxL<L:
        maxL = L
    if minR>R:
        minR = R
if maxL>minR:
    print(0)
elif maxL==minR:
    print(1)
elif maxL<minR:
    print(minR-maxL+1)
### BUGGY CODE ###

import math
#! //Users/daigofujiwara/anaconda3/bin python3

#h行で列和がyかy+1であるかどうかとサンプルを出力

input1=input()

input2=input()

x,y=input1.split(" ")
N,M=int(x),int(y)

A=input2.split(" ")

A=[int(a) for a in A ]

B=[]
for a in A:
    B.append(a//2)


Mb=max(B)
gmp=None

i=1
while True:
    m=Mb*i
    if m>M:
        break
    T=1
    for b in B:
        if not ((m//b)%2==1 and m%b==0):
            T=0
    if T==1:
        gmp=m
        break
    
    i+=1


if gmp is None:
    print(0)
else:
    print(int(math.floor(M/gmp+1.0)/2.0))




### FIXED CODE ###

import math
from functools import reduce
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
#! //Users/daigofujiwara/anaconda3/bin python3

#h行で列和がyかy+1であるかどうかとサンプルを出力

input1=input()

input2=input()

x,y=input1.split(" ")
N,M=int(x),int(y)

A=input2.split(" ")

A=[int(a) for a in A ]

B=[]
for a in A:
    B.append(a//2)


Mb=lcm_list(B)
gmp=None


T=1
for b in B:
    if not (Mb//b)%2==1:
        T=0
if T==1:
    gmp=Mb




if gmp is None:
    print(0)
else:
    print(int(math.floor(M/gmp+1.0)/2.0))
### BUGGY CODE ###

n, m, q = map(int, input().split())
cities = [[0] * (n + 1) for _ in range(n + 1)]
trains = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    trains[l][r] += 1

for i in range(n):
    for j in range(n):
        cities[i + 1][j + 1] = cities[i + 1][j] + trains[i + 1][j + 1]
for _ in range(q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p, q + 1):
        ans += cities[i][q] - cities[i][p - 1]
    print(ans)


### FIXED CODE ###

n, m, q = map(int, input().split())
cities = [[0] * (n + 1) for _ in range(n + 1)]
trains = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    trains[l][r] += 1

for i in range(n):
    for j in range(n):
        cities[i + 1][j + 1] = cities[i + 1][j] + trains[i + 1][j + 1]
for _ in range(q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p, q + 1):
        ans += cities[i][q] - cities[i][p - 1]
    print(ans)
### BUGGY CODE ###

from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    X = list(int(_) for _ in input().split())
    for i in range(N):
        X_tmp = [X[_] for _ in range(N) if _ != i]
        X_tmp.sort()        
        print(X_tmp[(N-2)//2])
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

from functools import reduce
import math
import copy
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    X = list(int(_) for _ in input().split())
    X_tmp = copy.deepcopy(X)
    X_tmp.sort()
    X_avg = (X_tmp[(N//2)-1] + X_tmp[(N//2)])/2
    for i in range(N):
        if X[i] > X_avg:
            print(X_tmp[(N//2)-1])
        else:
            print(X_tmp[(N//2)])
            
if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
    n, s = map(int, input().split())
    mod = 998244353
    a = list(map(int, input().split()))
    dp = [[0]*(s+1) for _ in range(n+1)]
    dp[0][0] = 1
    dio = dp[0]
    for i in range(1, n+1):
        ai = a[i-1]
        di = dp[i]
        for j in range(min(s+1, ai)):
            di[j] += 2*dio[j]
            di[j] %= mod
        for j in range(ai, s+1):
            di[j] += 2*dio[j]
            di[j] += dio[j-ai]
            di[j] %= mod
        dp[i] = di
        dio = di
    print(dp[n][s])
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n, s = map(int, input().split())
    mod = 998244353
    a = list(map(int, input().split()))
    dp = [[0]*(s+1) for _ in range(n+1)]
    dp[0][0] = 1
    dio = dp[0]
    for i in range(1, n+1):
        ai = a[i-1]
        di = dp[i]
        for j in range(min(s+1, ai)):
            di[j] = (di[j]+2*dio[j])%mod
        for j in range(ai, s+1):
            di[j] = (di[j]+2*dio[j]+dio[j-ai])%mod
        dp[i] = di
        dio = di
    print(dp[n][s])
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

str=input()
count=0
for i in range(0,len(str)-3):
    for j in range(4,len(str)-i+1):
        if int(str[i:j+i])%2019==0:
            count=count+1
            if j+4>len(str):
                break
            else:
                j=j+3
print(count)

### FIXED CODE ###

s=input()
b=[0]*2019
b[0]=1
now=0
m=2019
c=1
ans=0
for i in range(len(s)-1,-1,-1):
    now+=int(s[i])*c
    now=now%m
    c=c*10
    ans=ans+b[now]
    b[now]=b[now]+1
    c=c%m

print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
H = [int(i) for i in input().split()]
AB = [list(map(int, input().split())) for _ in range(int(M))]



count = 0
for i in range(N):
    flag = 1
    for j in range(M):
        if(AB[j][0] == i + 1):
            if(H[i] <= H[AB[j][1] - 1]):
                flag = 0
        if(AB[j][1] == i + 1):
            if(H[i] <= H[AB[j][0] - 1]):
                flag = 0
    if(flag == 1):
        count += 1

print(count)


### FIXED CODE ###

N, M = map(int, input().split())
H = [int(i) for i in input().split()]
AB = [list(map(int, input().split())) for _ in range(int(M))]


Flags = [1] * N

for j in range(M):
    if(H[AB[j][0] - 1] <= H[AB[j][1] - 1]):
        Flags[AB[j][0] - 1] = 0

    if(H[AB[j][1] - 1] <= H[AB[j][0] - 1]):
        Flags[AB[j][1] - 1] = 0

count = 0
for i in range(N):
    count += Flags[i]



print(count)
### BUGGY CODE ###

from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, g+1):
  while g % i == 0:
    g /= i
    prime.append(i)
print(len(set(prime)))


### FIXED CODE ###

from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

def factorize(g):
  factor = []
  for i in range(2, int(np.sqrt(g))+2):
    if g % i != 0:
      continue
    while g % i == 0:
      g //= i
    factor.append(i)
  if g != 1:
    factor.append(g)
  return factor
print(len(factorize(g))+1)
### BUGGY CODE ###

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

jumps = {}
lowest_cost = None

stack = []
if n == 2:
  stack.append((0, 1, 0))
elif n > 2:
  stack.append((0, 2, 0))
  stack.append((0, 1, 0))

while stack:
  current_index, next_index, cost = stack.pop()
  next_path = (current_index, next_index)
  if next_path not in jumps:
    jumps[next_path] = abs(stones[current_index] - stones[next_index])

  new_cost = cost + jumps[next_path]
  if next_index + 1 == n:
    if lowest_cost is None or new_cost < lowest_cost:
      lowest_cost = new_cost
  elif next_index + 2 == n:
    stack.append((next_index, next_index + 1, new_cost))
  else:
    stack.append((next_index, next_index + 2, new_cost))
    stack.append((next_index, next_index + 1, new_cost))

print(lowest_cost)

### FIXED CODE ###

def jump_cost(value1, value2):
  return abs(value1 - value2)

def stone_jump(n, stones):
  cost = [float("inf")] * n
  cost[0] = 0

  for index in range(len(stones) - 1):
    cost[index + 1] = min(cost[index + 1], cost[index] + jump_cost(stones[index], stones[index + 1]))
    if index + 2 < n:
      cost[index + 2] = min(cost[index + 2], cost[index] + jump_cost(stones[index], stones[index + 2]))

  print(cost[-1])
  return cost[-1]

n = int(input())
stones = [int(i) for i in input().split()]
stone_jump(n, stones)
### BUGGY CODE ###

n=int(input())
s=[]
count=0
for i in range(n):
    s.append(list(sorted(input())))
for i in range(n-1):
    for j in range(1+i,n):
        if s[i]==s[j]:
            count+=1
print(count)

### FIXED CODE ###

n = int(input())
count = {}
res = 0
for i in range(n):
  si = input()
  sortedSi = sorted(si)
  tSi = tuple(sortedSi)
  if tSi not in count:
    count[tSi] = 0
  res += count[tSi]
  count[tSi] += 1
print(res)
### BUGGY CODE ###

# ABC 118 D

def resolve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    A.reverse()

    costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

    dp = [0] * (N+1)
    for i in range(1, N+1):
        for a in A:
            if i - costs[a] < 0:
                continue
            dp[i] = max(dp[i-costs[a]] + 1, dp[i])

    ans = ""
    remain = dp[N]
    match = N

    while match > 0:
        for a in A:
            if match - costs[a] < 0:
                continue

            if match-costs[a] != 2 and match-costs[a] != 1 and dp[match-costs[a]] == remain-1:
                ans += str(a)
                match -= costs[a]
                remain -= 1
                break

    print(ans)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

# ABC 118 D

def resolve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

    dp = [-1] * (N+1)
    dp[0] = 0
    for i in range(1, N+1):
        for a in A:
            if i - costs[a] < 0:
                continue
            dp[i] = max(dp[i-costs[a]] + 1, dp[i])

    ans = ""
    remain = dp[N]
    match = N

    minCosts = 10
    for a in A:
        minCosts = min(minCosts, costs[a])

    while match > 0:
        for a in A:
            if match - costs[a] < 0 or 1<= match - costs[a] < minCosts:
                continue

            if dp[match-costs[a]] == remain-1:
                ans += str(a)
                match -= costs[a]
                remain -= 1
                break

    print(ans)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if (X + Y + Z == S):
                ans += 1
print(ans)


### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if (Z >= 0 and Z <= K):
            ans += 1
print(ans)
### BUGGY CODE ###

from collections import defaultdict
import sys


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


r, c, K = map(int, input().split())

dp = [{(i, j): 0 for i in range(r+1) for j in range(c+1)} for _ in range(4)]

# dp[N][i][j] := (i,j) にN個目でたどりつく方法
d = {(i, j): 0 for i in range(r+1) for j in range(c+1)}

for _ in range(K):
    r_, c_, v = map(int, input().split())
    d[(r_, c_)] += v
for i in range(1, r+1):
    for j in range(1, c+1):
        v = d[(i, j)]
        maxi = max(dp[k][(i-1, j)] for k in range(4))
        if v > 0:
            dp[0][(i, j)] = max(maxi, dp[0][(i, j-1)])
            dp[1][(i, j)] = max(dp[1][(i, j-1)], dp[0][(i, j-1)]+v, maxi+v)
            dp[2][(i, j)] = max(dp[2][(i, j-1)], dp[1][(i, j-1)]+v)
            dp[3][(i, j)] = max(dp[3][(i, j-1)], dp[2][(i, j-1)]+v)

        elif v == 0:
            dp[0][(i, j)] = max(dp[0][(i, j-1)], maxi)
            dp[1][(i, j)] = dp[1][(i, j-1)]
            dp[2][(i, j)] = dp[2][(i, j-1)]
            dp[3][(i, j)] = dp[3][(i, j-1)]


ans = max(dp[k][(r, c)] for k in range(4))

print(ans)

### FIXED CODE ###

from collections import defaultdict
import sys


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


r, c, K = map(int, input().split())

dp = [[[0]*(c+1) for _ in range(r+1)] for i in range(4)]

# dp[N][i][j] := (i,j) にN個目でたどりつく方法
d = [[0 for i in range(c+1)] for j in range(r+1)]

for _ in range(K):
    r_, c_, v = map(int, input().split())
    d[r_][c_] = v
for i in range(1, r+1):
    for j in range(1, c+1):
        v = d[i][j]
        if v > 0:
            maxi = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(maxi, dp[0][i][j-1])
            dp[1][i][j] = max(dp[1][i][j-1], dp[0][i][j-1]+v, maxi+v)
            dp[2][i][j] = max(dp[2][i][j-1], dp[1][i][j-1]+v)
            dp[3][i][j] = max(dp[3][i][j-1], dp[2][i][j-1]+v)

        elif v == 0:
            maxi = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(dp[0][i][j-1], maxi)
            dp[1][i][j] = dp[1][i][j-1]
            dp[2][i][j] = dp[2][i][j-1]
            dp[3][i][j] = dp[3][i][j-1]


ans = max(dp[k][r][c] for k in range(4))

print(ans)
### BUGGY CODE ###

import math
N = int(input())
for i in range(math.ceil(N**.5), N+1):
  if N%i == 0:
    print(len(str(i)))
    break

### FIXED CODE ###

N = int(input())
P = [i for i in range(1, int(N**.5)+1)][::-1]
for i in P:
  if N%i == 0:
    print(len(str(N//i)))
    break