#!/usr/bin/env python
# coding: utf-8

# In[27]:


def c_good(sarr,size,value):
    if size==1:
        if sarr[0]==chr(value):
            return 0
        else:
            return 1
    else:
        hsize = int(size/2)
        fhalf = sarr[:hsize]
        shalf = sarr[hsize:]
        chtr = chr(value)
        c1 =len([x for x in fhalf if x != chtr])
        c2 =len([x for x in shalf if x != chtr])
        m1 = c2+c_good(fhalf,hsize,value+1)
        m2 = c1+ c_good(shalf,hsize,value+1)
        return min(m1,m2)


# In[28]:


T = int(input())
for t in range(T):
    n = int(input())
    st = input()
    value = 97
    move =c_good(st,n,value)
    print(move)


# In[ ]:




