#K54767. Gemstone Count

    ID: 29827 Type: Default 1000ms 256MiB

Gemstone Count

Gemstone Count

You are given a collection of n strings. A gemstone is defined as a character that appears in every string in the collection. Your task is to determine the number of gemstones present.

Note: If n is 0, then there are no gemstones.

Detail: For each test case, the first line contains an integer n representing the number of strings. The following n lines each contain a string consisting of lowercase English letters. A gemstone is any letter that appears in all of the n strings. Find the number of such gemstone characters.

The mathematical formulation can be described in LaTeX as follows:

\( \text{Let } S_1, S_2, \dots, S_n \text{ be the strings. Define } G = \bigcap_{i=1}^{n} \{ c : c \in S_i \} \text{. The answer is } |G|. \)

inputFormat

The input is read from standard input and is structured as follows:

  • The first line contains an integer n — the number of strings.
  • The next n lines each contain a non-empty string composed of lowercase English letters.

outputFormat

Print a single integer on a new line — the number of gemstone characters that occur in every one of the input strings.

## sample
3
abcdde
baccd
eeabg
2

</p>