description: You are given an integer array a_1, a_2, ..., a_n and integer k.
  
  In one step you can 
  
    * either choose some index i and decrease a_i by one (make a_i = a_i - 1); 
    * or choose two indices i and j and set a_i equal to a_j (make a_i = a_j). 
  
  
  
  What is the minimum number of steps you need to make the sum of array ∑_{i=1}^{n}{a_i} ≤ k? (You are allowed to make values of array negative).
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.
  
  The first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ k ≤ 10^{15}) — the size of array a and upper bound on its sum.
  
  The second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the array itself.
  
  It's guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case, print one integer — the minimum number of steps to make ∑_{i=1}^{n}{a_i} ≤ k.
  
  Example
  
  Input
  
  
  4
  1 10
  20
  2 69
  6 9
  7 8
  1 2 1 3 1 2 1
  10 1
  1 2 3 1 2 6 1 6 8 10
  
  
  Output
  
  
  10
  0
  2
  7
  
  Note
  
  In the first test case, you should decrease a_1 10 times to get the sum lower or equal to k = 10.
  
  In the second test case, the sum of array a is already less or equal to 69, so you don't need to change it.
  
  In the third test case, you can, for example: 
  
    1. set a_4 = a_3 = 1; 
    2. decrease a_4 by one, and get a_4 = 0. 
  
  As a result, you'll get array [1, 2, 1, 0, 1, 2, 1] with sum less or equal to 8 in 1 + 1 = 2 steps.
  
  In the fourth test case, you can, for example: 
  
    1. choose a_7 and decrease in by one 3 times; you'll get a_7 = -2; 
    2. choose 4 elements a_6, a_8, a_9 and a_{10} and them equal to a_7 = -2. 
  
  As a result, you'll get array [1, 2, 3, 1, 2, -2, -2, -2, -2, -2] with sum less or equal to 1 in 3 + 4 = 7 steps.
solution: import sys
  # from abc import abstractmethod
  # from collections import deque
  import math
  # from typing import AnyStr 
  import heapq
  # import random
  # import copy
  # from decimal import Decimal
  # from collections import defaultdict
  # from typing import AnyStr
  
  INF = int(1e15 + 1)
  mod = 1000000007
  
  read = sys.stdin.readline
  sys.setrecursionlimit(10**5)
  dx = [0 , 1, 0, -1]
  dy = [-1, 0, 1, 0]
  seg = []
  
  def power(bottom, up):
      # print(bottom, up)
      if up == 1:
          return bottom
      elif up == 0:
          return 1
      tmp = power(bottom, int(up // 2))
      if up % 2 == 0:
          return (tmp * tmp)
      else:
          return (tmp * tmp * bottom)
  
  def modpower(bottom, up):
      print(bottom, up)
      if up == 1:
          return bottom
      elif up == 0:
          return 1
      tmp = power(bottom, int(up // 2))
      if up % 2 == 0:
          return (tmp * tmp) % mod
      else:
          return (tmp * tmp * bottom) % mod
  
  def ccw(p1, p2, p3):
      a = p2[0] - p1[0]
      b = p2[1] - p1[1]
  
      c = p3[0] - p1[0]
      d = p3[1] - p1[1]
  
      tmp = a * d - b * c
  
      if tmp > 0:
          return 1
      elif tmp == 0:
          return 0
      else:
          return -1
  
  def lower_bound(item):
      left =0 
      right = len(queue)
  
      while left < right:
          mid = int((left + right) // 2)
          if queue[mid] >= item:
              right = mid
          elif queue[mid] < item:
              left = mid + 1
  
      return int((left + right)// 2)
  
  def make_seg(left, right, node):
      if left == right:
          seg[node] = arr[left - 1]
          return seg[node]
      
      mid = int((left + right) // 2)
      seg[node] = make_seg(left , mid , node * 2)
      seg[node] += make_seg(mid + 1 , right , node * 2 + 1)
  
      return seg[node]
  
  def seg_replace(left , right, node,index, diff):
      if index < left or index > right:
          return
  
      seg[node] += diff
      if left == right:
          return
      
      mid = (left + right) // 2
      seg_replace(left , mid , node * 2 , index, diff)
      seg_replace(mid + 1 , right , node *2 + 1, index,  diff)
  
  def seg_sum(left, right, start , end, node):
      if start <= left and right <= end:
          return seg[node]
  
      if end < left or start > right:
          return 0
  
      mid = (left+right) // 2
  
      return seg_sum(left , mid , start , end, node * 2) + seg_sum(mid + 1 , right , start , end, node * 2 + 1)
  
  def lazy_seg_replace(left, right, node,  start, end , diff):
      if seg_lazy[node] != 0:
          seg[node] += seg_lazy[node] * (right - left + 1)
  
          if left != right:
              seg_lazy[node * 2] += seg_lazy[node]
              seg_lazy[node * 2 + 1] += seg_lazy[node]
          
          seg_lazy[node] = 0
  
      if start<= left and right <= end:
          seg_lazy[node] += diff
          seg[node] += seg_lazy[node] * (right - left + 1)
  
          if left != right:
              seg_lazy[node * 2] += seg_lazy[node]
              seg_lazy[node * 2 + 1] += seg_lazy[node]
          
          seg_lazy[node] = 0
          return seg[node]
      
      if end < left or start > right:
          return seg[node]
      
  
      mid = (left + right) // 2
  
      seg[node] = lazy_seg_replace(left, mid, node * 2 , start , end, diff)
      seg[node] += lazy_seg_replace(mid + 1 , right , node * 2 + 1 , start , end , diff)
  
      return seg[node]
  
  def lazy_seg_sum(left , right, node , start , end):
      # print(left , right , start, end)
      if seg_lazy[node] != 0:
          seg[node] += seg_lazy[node] * (right - left + 1)
  
          if left != right:
              seg_lazy[node * 2] += seg_lazy[node]
              seg_lazy[node * 2 + 1] += seg_lazy[node]
          
          seg_lazy[node] = 0
      
      if start <= left and right <= end:
          tmp = seg[node]
          seg[node] = 0
          return tmp
      
      if end < left or right < start:
          return 0
      
      mid = (left+ right) // 2
      if mid >= end:
          tmp = lazy_seg_sum(left , mid , node * 2 , start , end)
      else:
          tmp = lazy_seg_sum(mid + 1 , right , node * 2  + 1, start , end)
  
      seg[node] -= tmp
      return tmp
      # return lazy_seg_sum(left , mid , node * 2 , start , end) + lazy_seg_sum(mid + 1 , right , node * 2 + 1 , start,  end) 
          
  def seg_index(left , right,  node , idx):
      seg[node] -= 1
      if left == right:
          return left
      mid = (left + right) // 2
      if seg[node * 2] < idx:
          return seg_index(mid + 1 , right , node * 2 + 1 , idx - seg[node * 2])
      else:
          return seg_index(left , mid , node * 2 , idx )
  
  loop = int(read())
  # li = list(map(int, read().strip().split()))
  
  answer_li  =[]
  for _ in range(loop):
      num, goal = map(int, read().strip().split())
      second = list(map(int ,read().strip().split()))
  
      second.sort()
  
      answer = sum(second) - goal
  
      if sum(second) <= goal:
          answer_li.append(0)
          continue
      elif num == 1:
          answer_li.append(second[0] - goal)
          continue
  
      first_num = second[0]
      tmp = 0
      # print(second)
      for idx in range(1, num):
          tmp1 = (num - idx + 1) * first_num - goal
          tmp2 = math.ceil(tmp1 / (num - idx + 1))
          # print(idx ,goal,  tmp1 , tmp2)
          tmp2 = max(0 , tmp2)
  
          answer = min(answer , num - idx + tmp2)
  
          goal -= second[idx]
          # print(idx , answer , num - idx + tmp2 , num - idx)
  
      answer = max(answer , 0)    
      answer_li.append(answer)
  
  # print("\n".join(answer_li))
  print("\n".join(map(str , answer_li)))