def aux(input_s, const):
    if(len(input_s) == 1):
        return int(input_s != const) 
    
    mid = len(input_s) // 2
 
    fps = input_s[:mid]
    sps = input_s[mid:]
 
    const_1 = chr(ord(const))
    
    first = aux(fps, const_1)
    first_result = 0
    for l in sps:
      if(l == const):
        first_result += 1
    first += len(input_s)//2 - first_result  
    second = aux(sps, const_1)
    second_result = 0
    for l in fps:
      if(l == const):
        second_result += 1
    second += len(input_s)//2 - second_result
 
    return min(first, second)
 
input_n = int(input())
for i in range(input_n):
    n = int(input())
    input_s = input()
    print(aux(input_s, 'a'))
