def agood(string,length, entry):
  if(length == 1):
    if(string == entry):
      return 0
    else:
      return 1

  center = length // 2
  left = string[:center]
  right = string[center:]
  next_chr = chr(ord(entry) + 1)
  
  count_left = len(left) - left.count(entry) + agood(right,center, next_chr)
  count_right = len(right) - right.count(entry) + agood(left, center, next_chr)

  return count_left if count_left < count_right else count_right

entry = int(input())
initial_entry = 'a'
for _ in range(entry):
  length = int(input())
  string = input()
  print(agood(string.strip(),length, initial_entry))