Joshua’s Rocks

5

1 votes
Problem

Joshua has collected various rocks. Each rock has various minerals embeded in it. Each type of mineral is designated by a uppercase letter in the range ascii [A - Z]. There may be multiple occurrences of a mineral in a rock. A mineral is called a gemstone if it occurs at least once in each of the rocks in Joshua collection.

Given a list of minerals embedded in each of Joshua's rocks, display the number of types of gemstones he has in his collection.

For example, the array of mineral composition strings arr = [abc, abc, bc] . The minerals b and c appear in each composite, so there are 2 gemstones.

Input Format

The first line consists of an integer n, the size of arr.
Each of the next n lines contains a string arr[i] where each letter represents an occurence of a mineral in the current rock.

Constraints

1 ≤ n ≤ 1000

1 ≤ | arr[i] | ≤ 1000
Each composition arr[i] consists of only upper-case Latin letters ('A’-'Z').

Output Format

Print the number of types of gemstones in Joshua's collection. If there are none, print 0.

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

Sample Input

3

ABCDDE

BACCD

EEABG

Sample Output

2

Explanation

Only A and B are gemstones because they are the only types that occur in every rock.

Editor Image

?