#K6831. Count Distinct Items

    ID: 32836 Type: Default 1000ms 256MiB

Count Distinct Items

Count Distinct Items

You are given a list of items (strings) and an integer n representing the number of items. Your task is to determine the number of distinct items after normalizing each item by trimming any leading and trailing spaces and converting all characters to lowercase.

For example, if two items differ only in case or extra spaces, they are considered identical after normalization. The mathematical formulation can be written as follows:

Let \( S = \{ s_1, s_2, \dots, s_n \} \) be the set of input strings. Define the normalization function \( f(s) = \text{lowercase}(\text{trim}(s)) \). You need to compute the cardinality of the set \( \{ f(s) : s \in S \} \), i.e. \( |\{ f(s) : s \in S \}| \).

Input is provided through standard input and output must be printed to standard output.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 103), representing the number of items. The following n lines each contain one string representing an item. Each string may have leading or trailing spaces and can contain any mix of uppercase and lowercase letters.

outputFormat

Output a single integer which is the number of distinct items after normalizing them (trimming spaces and converting to lowercase).

## sample
5
Apple 
  apple
Orange
Banana
 BANANA  
3

</p>