import sys
input = sys.stdin.readline

def aGood(string, n, l, r, a):
  if l==r:
    if ord(string[l]) - a == 0:
      return 0
    else:
      return 1
  else:
    cost1 = 0
    cost2 = 0
    mid = (l + r) // 2;
    for i in range(l, mid + 1):
      if ord(string[i]) != a:
        cost1 += 1
    for i in range(mid+1, r + 1):
      if ord(string[i]) != a:
        cost2 += 1

    return min(cost1 + aGood(string, n, (l+r)//2 + 1, r, a + 1), cost2 + aGood(string, n, l, (l+r)//2, a+1))

  


def solution():
  n = int(input())
  string = input()
  

  # print(leftmark, 'left')
  print(aGood(string, n, 0, n-1, 97))

t = int(input());
for i in range(0, t):
  solution()
  
