# -*- coding: utf-8 -*-
"""
Created on Fri Jul 17 19:40:00 2020

@author: shubham gupta
"""
def two(n, r, s):
    if n == 1:return 1 - s.count(chr(r))
    a = s[:n//2];b = s[n//2:]
    return min(n//2-a.count(chr(r))+two(n//2, r+1, b), n//2-b.count(chr(r))+two(n//2, r+1, a))
for _ in range(int(input())):print(two(int(input()), 97, input()))