def rec(s, let, L, R):
    if L == R:
        if s[L] == let:
            return 0
        return 1
        
    mid = (L+R) // 2
    mid2 = (L+R)//2
    
    change = 0
    chan = 0
    # print(L, R, mid)
    
    for i in range(L, mid+1):
        if s[i] != let:
            change += 1
    for i in range(mid2+1, R+1):
        if s[i] != let:
            chan += 1
    cntl = rec(s, dic2[dic[let]+1], mid+1, R) + change
    cntr = rec(s, dic2[dic[let]+1], L, mid) + chan
    
    return min(cntl, cntr)
    
    
def rec2(s, let, L, R):
    if L ==R:
        if s[L] != let:
            return 1
        return 0
        
    mid = (L+R)//2
    chan = 0
    
    for i in range(mid+1, R+1):
        if s[i] != let:
            chan += 1
            
    return chan
        
for _ in range(int(input())):
    n = int(input())
    s = input()
    let = "abcdefghijklmnopqrstuvwxyz"
    dic, dic2 = {}, {}
    for i in range(26):
        dic[let[i]] = i
        dic2[i] = let[i]
    
    print(rec(s, 'a', 0, n-1))

