#K50992. Unique Identifier Modification

    ID: 28987 Type: Default 1000ms 256MiB

Unique Identifier Modification

Unique Identifier Modification

You are given a list of identifiers (strings). Your task is to determine the minimum number of character modifications required to make all identifiers unique. In one modification, you are allowed to change exactly one character in an identifier to any lowercase English letter.

For example, if the list contains duplicate identifiers, you only need to modify some of them while leaving one occurrence unchanged. Note that each modification is done by altering just one character in the identifier.

The idea is that if an identifier id appears k times, you need to modify k-1 occurrences. However, the modifications must yield new identifiers that do not already appear in the list, including those from previous modifications.

Theoretical consideration: One may informally view the required modifications as
$$\text{modifications} = \sum_{id \in S} (\text{frequency}(id) - 1),$$
but ensuring uniqueness may force specific character substitutions.

inputFormat

The first line of input contains an integer n representing the number of identifiers. The following n lines each contain a string, which is an identifier.

outputFormat

Output a single integer representing the minimum number of modifications needed to ensure all identifiers are unique.

## sample
4
abc
abc
bbb
ccd
1