import java.util.*; 
import java.io.*;
import java.math.*;

public class Main
{ 	
	public static void main(String[] args)throws Exception
	{
	    Reader reader = new Reader();
		reader.readLine();
		int t = reader.readInt(0);

		StringBuilder res = new StringBuilder();
		while (t-- > 0)
		{
			reader.readLine();
			int n = reader.readInt(0);

			reader.readLine();
			char a[] = reader.readString(0).toCharArray(); 	

			res.append(calc(a, 0, n - 1, 'a')).append("\n");	
		}

		System.out.println(res.toString().trim());
		reader.close();
	}

	private static int calc(char arr[], int st, int ed, char ch)
	{
		if (st == ed)
		{
			return arr[st] == ch ?0: 1;
		}

		int mid = (ed + st) / 2;
		int ans1= getDiffCount(arr, mid + 1, ed, ch) + calc(arr, st, mid, (char)(ch+1));
		int ans2= getDiffCount(arr, st, mid, ch) + calc(arr, mid + 1, ed, (char)(ch + 1));
		return ans1 > ans2 ?ans2: ans1;
	}

	private static int getDiffCount(char arr[], int st, int ed, char ch)
	{
		int ans=0;
		for (int i=st;i <= ed;++i)
		{
			if (arr[i] != ch)
			{
				++ans;
			}
		}
		return ans;
	}
}

class Pair
{
	int index;
	int level;

	public Pair(int index, int level)
	{
		this.index = index;
		this.level = level;
	}

	@Override
	public String toString()
	{
		return index + " " + level;
	}

}

class Reader
{     
    private BufferedReader reader; 
    private String line[];     

    public Reader()     
    {         
        reader = new BufferedReader(new InputStreamReader(System.in));     
    }     

    public String[] getLine()     
    {         
        return line;     
    }     

    public boolean readLine()     throws IOException 
    {         
        String str = reader.readLine();
        if (str == null || str.isEmpty())
            return false;
        line = line = str.split(" ");
        return true;
    }    

    public List<Integer> getIntegersList()
    {
        List<Integer> res = new ArrayList<>();
        for (String str:line)
            res.add(Integer.parseInt(str));
        return res;

    }

	public Set<Integer> getIntegersSet()
    {
        Set<Integer> res = new HashSet<>();
        for (String str:line)
            res.add(Integer.parseInt(str));
        return res;

    }

	public List<Long> getLongsList()
    {
        List<Long> res = new ArrayList<>();
        for (String str:line)
            res.add(Long.parseLong(str));
        return res;

    }

    public int readInt(int pos)throws IOException     
    {         
        return Integer.parseInt(line[pos]);     
    }     

    public double readDouble(int pos)throws IOException     
    {         
        return Double.parseDouble(line[pos]);     
    }     

    public long readLong(int pos)throws IOException 
    {         
        return Long.parseLong(line[pos]); 
    }     

    public String readString(int pos)throws IOException     
    {         
        return line[pos];     
    }     

    public void close()throws IOException 
    {         
        reader.close();     
    }
}





		