//package codeforces;

import java.util.Scanner;
import java.util.ArrayList;

public class Codeforces {
    
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        
        for(int i = 0; i < n; i++){
            int len = in.nextInt();
            String str = in.next();
            int count = good_string(str, 0, len, 'a');
            System.out.println(count);
        }
        
    }
    
    public static int not_equals_count(String str, int start, int end, char c){
        int count = 0;
        for(int i = start; i < end; i++){
            if(str.charAt(i) != c) count++;
        }
        return count;
    }
    
    public static int good_string(String str, int start, int end, char c){
        if(end - start == 1){
            if(str.charAt(start) == c) return 0;
            else return 1;
        }
        else {
            char next = (char) (c + 1);
            int a = good_string(str, start, start + (end - start) / 2, next) + not_equals_count(str, start + (end - start) / 2, end, c);
            int b = good_string(str, start + (end - start) / 2, end, next) + not_equals_count(str, start, start + (end - start) / 2, c);
            return Math.min(a, b);
        }
    }
    
}

