Uniform Maker
InterviewTime limit1sMemory limit1024 MB
Given N words of equal length, find the total minimum number of character changes needed to make all words identical.
Problem
The International Costumes and Props Company (ICPC) received an order from a client to produce pennants that each contain the same word. Because of a miscommunication between the account manager and the client, the pennants do not all show the same word, although every word has the same length. Reproducing the pennants is costly because ICPC only uses a rare type of fabric.
The client did not specify the word. The client is satisfied only if all pennants show the same word.
ICPC can change one character in a word into another character. This is expensive, but cheaper than making a new pennant. ICPC wants to minimize how many times it uses this technique. Find the minimum total number of characters that must be changed so that the client is satisfied.
For example, take the six words calf, palm, book, icpc, ball, and room. Changing all of them to balm needs 14 character changes in total, which is the minimum for this set.
Input
The first line contains two integers and (, ), the number of pennants and the length of each word. Each of the next lines contains a string with , the word on the -th pennant. Every string contains only lowercase English letters.
Output
Print one integer on a line: the minimum total number of characters that must be changed so that all pennants show the same word.