logo AlgoBeat OnlineJudge
登录 注册

#215668. [ICPC 2021 Jakarta R] Uniform Maker

内存限制:256 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The International Costumes and Props Company (ICPC) received an order from a client to produce pennants each containing the same word. However, due to some miscommunication between the account manager and the client, not all the produced pennants have the same word although all of them have a word of the same length. Reproducing those pennants is very costly as the ICPC only uses a certain type of rare fabric in their production.

Fortunately, the client didn't specify the word that they want to be in the pennants. In fact, the client will be satisfied if and only if all the pennants have the same word.

The ICPC has a special technique to change one character in a word into some other character. It is expensive, albeit not as expensive as reproducing a new pennant. Therefore, the ICPC has to minimize the number of times they have to use such a technique. Your task in this problem is to help the ICPC to determine the minimum total number of characters that need to be changed so that the client will be satisfied.

For example, let there be pennants with the following words: calf, palm, book, icpc, ball, and room. The total number of characters that need to be changed can be minimized if all the words are changed into balm.

  • calf → 2 characters: b**m
  • palm → 1 characters: b***
  • book → 3 characters: *alm
  • icpc → 4 characters: balm
  • ball → 1 characters: ***m
  • room → 3 characters: bal*

The symbol * represents an unchanged character. There are a total of characters that need to be changed in this example.

输入格式

Input begins with a line containing two integers (; ) representing the number of pennants and the length of each word in the pennant, respectively. The next line each contains a string () representing the word on the pennant. Each string only contains lowercase alphabetical characters.

输出格式

Output contains an integer in a line representing the minimum total number of characters that need to be changed so that the client will be satisfied.

样例

样例输入 1

6 4
calf
palm
book
icpc
ball
room

样例输出 1

14

样例输入 2

3 11
goodluckfor
icpcjakarta
contestants

样例输出 2

19

样例输入 3

5 14
helpiamtrapped
inanincfactory
forthreemonths
withoutfoodand
drinkandshower

样例输出 3

49