while True:
    try:
        n = int(input())
        names = [input() for _ in range(n)]
        for name in names:
            dic = {}
            for c in name:
                if c not in dic:
                    dic[c] = 1
                else:
                    dic[c] += 1
            lst = list(sorted(dic.values(), reverse=True))
            total, point = 0, 26
            for i in lst:
                total += point * i
                point -= 1
            print(total)
    except:
        break