NINJA2 - PATHETIC STRINGS

A string is said to be “PATHETIC” if all the characters in it are repeated the same number of times. You are given a string of length n, what is the minimum number of changes required to make a string “PATHETIC”. The string has only lower case letters and you can change any letter to any other letter.

Input Format

The first line contains an integer T, the number of test cases. This is followed by T test cases each containing 1 line: Each testcase consists of a string composed of lowercase letters.

Output Format

For each testcase, print in a new line the minimum number of changes required.

Constraints

1 ≤ T ≤ 1370

1 ≤ n ≤ 1991

Sample

Input:
2
bbaccaaa
ccaacb

Output:
2
1

Added by:mombassa
Date:2016-02-17
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY

hide comments
2016-02-20 18:07:01 Ankit
My code runs properly on ideone giving correct result. But it gives SIGSEGV run time error on spoj.
@mombasa, can u help ?

Last edit: 2016-02-20 18:14:54
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.