class Main:
    def main(self):
        t = int(input())
        for t1 in range(0, t):
            input()
            s1 = input()
            self.min = len(s1)
            self.check(s1, "a", 0)
            print(self.min)

    def check(self, s, c, count):
        #print(s, c, count)
        if len(s) == 1:
            count += (0 if s == c else 1)
            self.min = min(self.min, count)
        else:
            s1 = s[0:len(s) // 2]
            s2 = s[len(s) // 2:]
            self.check(s1, chr(ord(c) + 1), count + (len(s2) - s2.count(c)))
            self.check(s2, chr(ord(c) + 1), count + (len(s1) - s1.count(c)))

Main().main()
