#C9247. Common Minerals
Common Minerals
Common Minerals
You are given T rock samples represented as strings of lowercase letters, where each letter corresponds to a mineral found in that rock. Your task is to find the number of minerals that are common to all rock samples. In other words, if we define (S_i) as the set of minerals in the (i^{th}) rock sample, you must compute (|\bigcap_{i=1}^{T} S_i|).
For example, if the input is:3
abcdde
baccd
eeabg
then the common minerals are 'a' and 'b', and the output should be 2
.
inputFormat
The input is provided via standard input and consists of multiple lines. The first line contains a single integer (T) ((1 \le T \le 10^4)), the number of rock samples. The following (T) lines each contain a non-empty string composed only of lowercase letters, representing a rock sample.
outputFormat
Output a single integer representing the number of minerals (letters) that appear in every rock sample.## sample
3
abcdde
baccd
eeabg
2