'''import bisect
power=[pow(2,i) for _ in range(18)]'''
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
def getcost(l,r,ch):
    global s
    cnt=0
    for i in range(l,r+1):
        if s[i]!=ch:
            cnt+=1
    return cnt



def getmin(l,r,ch):
    global s
    if l==r:
        if s[l]==ch:
            return 0
        else:
            return 1
    mid=(l+r)//2
    return min(getcost(l,mid,ch)+getmin(mid+1,r,chr(ord(ch)+1)),getcost(mid+1,r,ch)+getmin(l,mid,chr(ord(ch)+1)))
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for _ in range(int(input())):
    n=int(input())
    s=input()
    print(getmin(0,n-1,'a'))
