There is a collection of rocks where each rock has various minerals embeded in it.  Each type of mineral is designated by a lowercase letter in the range $a s c i i[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 the collection.

Given a list of minerals embedded in each of the rocks, display the number of types of gemstones in the collection.

Example 

$arr=[\text{'abc'},\text{'abc'},\text{'bc'}]$  

The minerals $\boldsymbol{b}$ and $\textbf{C}$ appear in each rock, so there are $2$ gemstones.

Function Description  

Complete the gemstones function in the editor below.    

gemstones has the following parameter(s):  

string arr[n]: an array of strings   

Returns  

int: the number of gemstones found 

Input Format

The first line consists of an integer $n$, the size of $\textbf{arr}$. 

Each of the next $n$ lines contains a string $arr\left[i\right]$ where each letter represents an occurence of a mineral in the current rock.

Constraints

$1\leq n\leq100$ 

$1\leq$ | arr[i] | $\leq100$ 

Each composition $arr\left[i\right]$ consists of only lower-case Latin letters ('a'-'z').  

Sample Input
STDIN       Function
-----       --------
3           arr[] size n = 3
abcdde      arr = ['abcdde', 'baccd', 'eeabg']
baccd
eeabg

Sample Output
2

Explanation

Only $a$ and $\boldsymbol{b}$ occur in every rock.

Difficulty: EASY

Solutions:
import string
n = int(input())
ans = set(string.ascii_lowercase)
for i in range(n):
	s = set(input())
	ans &= s
print(len(ans))


import sys
import string

def read_numbers(line=None):
	if line is None:
		line = sys.stdin.readline()
	return [int(x) for x in line.split()]
n = read_numbers()[0]
gem_elements = set(string.ascii_lowercase)
for i in range(n):
	stone = sys.stdin.readline().strip()
	gem_elements = gem_elements & set(stone)
print(len(gem_elements))


d = {}
n = int(input())
for t in range(n):
	st = input()
	for i in st:
		if i in d:
			if d[i][1] < t:
				d[i] = (d[i][0] + 1, t)
		else:
			d[i] = (1, t)
print(len([k for k in d if d[k][0] == n]))


import string
numLines = int(input())
prevSet = set(string.ascii_lowercase)
for _ in range(numLines):
	prevSet = prevSet.intersection(set(input()))
print(len(prevSet))


import sys

def solve(new_set, initial_set):
	return new_set & initial_set
if len(sys.argv) < 2:
	input = sys.stdin
else:
	input = open(sys.argv[1])
n = int(input.readline()) - 1
initial_set = {char for char in input.readline().strip()}
for x in range(n):
	new_set = {char for char in input.readline().strip()}
	initial_set = solve(new_set, initial_set)
print(len(initial_set))


rocks = int(input())
z = []
for i in range(rocks):
	z.append(set(input()))
x = z[1].__rand__(z[0])
for i in z[1:]:
	x = x.__rand__(i)
print(len(x))


N = int(input())
x = set([e for e in input()])
for n in range(N - 1):
	x = x.intersection(set([e for e in input()]))
print(len(x))


strings = []
ans = ''
rockNum = int(input())
for i in range(rockNum):
	strings.append(input())
ans = strings[0]
for k in strings:
	ans = set(ans) & set(k)
print(len(ans))


import sys
n = int(input())
list = []
leng = []
alpha = []
count = 0
small = []
for i in range(n):
	elem = input()
	list += [elem]
	leng += [len(elem)]
i = 0
while i < n:
	if leng[i] == min(leng):
		small = list[i]
		break
	i += 1
for j in small:
	if alpha.count(j) > 0:
		pass
	else:
		alpha += [j]
for k in alpha:
	hit = 0
	for l in list:
		if l.count(k) > 0:
			hit += 1
	if hit == n:
		count += 1
print(count)


d = {}
t = int(input())
for e in range(t):
	for s in set(input()):
		try:
			d[s] += 1
		except:
			d[s] = 1
print(len([i for i in d if d[i] == t]))


numCases = int(input())
cases = []
for i in range(0, numCases):
	cases.append(list(set(input())))
intersects = cases[0]
for i in range(1, numCases):
	intersects = [x for x in cases[i] if x in intersects]
print(len(intersects))


def prog():
	rocks = [set(list(str(input()))) for i in range(int(input()))]
	print(len(set.intersection(*rocks)))
prog()


n = int(input())
scount = ''
for i in range(0, n):
	strg = input()
	uniqueSorted = ''.join(sorted(set(strg)))
	if i > 0:
		tempStr = ''
		for i in range(0, len(scount)):
			if uniqueSorted.find(scount[i]) != -1:
				tempStr = tempStr + scount[i]
		scount = tempStr
	else:
		scount = uniqueSorted
print(len(scount))


__author__ = 'stefanp'
import sys
import functools as ft
N = int(sys.stdin.readline())
res = []
for i in range(N):
	res.append(set(list(sys.stdin.readline().rstrip())))
left = ft.reduce(lambda x, y: x.intersection(y), res)
print(len(left))


import sys
data = sys.stdin.readlines()
rock_list = data[1:]
first_set = set()
second_set = set()
for first_rock in data[1:2]:
	for first_rock_element in first_rock:
		first_set.add(first_rock_element)
first_set.remove('\n')
for rock in data[2:]:
	second_set.clear()
	for element in rock:
		if element != '\n':
			second_set.add(element)
	first_set = first_set.intersection(second_set)
print(len(first_set))


import functools, sys
N = int(sys.stdin.readline())
rocks = [sys.stdin.readline().strip() for _ in range(N)]
print(len(functools.reduce(set.intersection, map(set, rocks))))


import fileinput
stones = []
gems = []
for line in fileinput.input():
	if fileinput.lineno() == 1:
		lengths = int(line)
	else:
		stones.append(line.strip())
for x in range(0, len(stones[0])):
	if stones[0][x] not in gems:
		gems.append(stones[0][x])
		for y in range(0, lengths):
			if stones[0][x] not in stones[y]:
				try:
					gems.remove(stones[0][x])
				except ValueError:
					continue
print(len(gems))


N = int(input())
s = set('abcdefghijklmnopqrstuvwxyz')
for n in range(N):
	s &= set(input())
print(len(s))


N = int(input())
l = [set(input()) for i in range(N)]
s = l[0]
for i in l:
	s &= i
print(len(s))


numStones = int(input())
gemStones = []
for i in range(numStones):
	gemStones.append(input())
shortest = 0
for i in range(1, numStones):
	if len(gemStones[i]) < len(gemStones[shortest]):
		shortest = i
for e in gemStones[shortest]:
	if gemStones[shortest].count(e) > 1:
		i = gemStones[shortest].index(e)
		gemStones[shortest] = gemStones[shortest][:i] + gemStones[shortest][i + 1:]
gemElements = []
for e in gemStones[shortest]:
	elementCount = 0
	for g in gemStones:
		if e in g:
			elementCount += 1
	if elementCount == numStones:
		gemElements.append(e)
print(len(gemElements))


N = int(input())
words = []
for _ in range(N):
	words.append(input())
d = {}
s = 0
for l in range(ord('a'), ord('z') + 1):
	l = chr(l)
	for w in words:
		if l not in w:
			break
	else:
		s += 1
print(s)


import sys

class Minerals:
	rocks = []

	def addRock(self, rock):
		self.rocks.append(rock)

	def getGem(self):
		mineral_count = {}
		num_rocks = self._getNumRocks()
		num_gems = 0
		for rock in self.rocks:
			minerals_seen_in_rock = {}
			for mineral in rock:
				try:
					minerals_seen_in_rock[mineral]
				except:
					minerals_seen_in_rock[mineral] = True
					try:
						mineral_count[mineral] += 1
					except:
						mineral_count[mineral] = 1
		for val in mineral_count.values():
			if val == num_rocks:
				num_gems += 1
		return num_gems

	def _getNumRocks(self):
		return len(self.rocks)
num_test_cases = sys.stdin.readline().strip('\n')
minerals = Minerals()
for line in sys.stdin:
	minerals.addRock(line.strip('\n'))
print(minerals.getGem())


import sys
data = sys.stdin.readlines()
alfabeto = 'abcdefghijklmnopqrstuvwxyz'
d = {}
for l in alfabeto:
	d[l] = 0
n = int(data[0])
for el in data[1:]:
	for l in alfabeto:
		if l in el:
			d[l] += 1
tot = 0
for (k, v) in d.items():
	if v == n:
		tot += 1
print(tot)


numRocks = int(input())
rocks = []
for i in range(numRocks):
	rocks.append(input())
gemCounter = 0
gems = ''
for element in 'abcdefghijklmnopqrstuvwxyz':
	gemElement = True
	for rock in rocks:
		if not element in rock:
			gemElement = False
			break
	if gemElement:
		gemCounter += 1
		gems += element
print(gemCounter)


n = int(input())
s = []
count = 0
flag = 1
for x in range(0, n):
	a = input()
	s += [a]
for x in range(0, len(s[0])):
	b = s[0][x]
	for y in range(1, n):
		if b in s[y]:
			flag = 1
			s[y] = s[y].replace(b, '')
		else:
			flag = 0
			break
	if flag == 1:
		count = count + 1
print(count)


import string
numberOfRocks = int(input())
rocks = []
gems = 0
for i in range(numberOfRocks):
	rocks.append(input())
for letter in string.ascii_lowercase:
	for rock in rocks:
		if not letter in rock:
			break
	else:
		gems += 1
print(gems)


import sys
import string
N = int(input())
S = set(input())
for i in range(N - 1):
	R = set(input())
	S = S.intersection(R)
print(len(S))


from string import ascii_lowercase
harfler = ascii_lowercase
n = int(input())
r = []
toplam = 0
for i in range(n):
	r.append(input())
for t in harfler:
	c = 0
	for z in r:
		if t in z:
			c += 1
	if c == n:
		toplam += 1
print(toplam)


n = int(input())
assert n >= 1
assert n <= 100
johnRocks = []
for i in range(0, n):
	johnRocks.append(input())
index = []
for i in range(0, len(johnRocks)):
	if i == 0:
		for j in johnRocks[i][:]:
			if index.count(j) == 0:
				index += j
	if i > 0:
		for k in index[:]:
			if johnRocks[i].find(k) < 0:
				index.remove(k)
print(len(index))


rocks = []
n = int(input())
for index in range(0, n):
	rocks.append(str(input()))
elements = {}
for (index, rock) in enumerate(rocks):
	for element in list(set(rock)):
		try:
			elements[element] += 1
		except KeyError:
			elements[element] = 1
answer = 0
for element in elements:
	if elements[element] >= n:
		answer += 1
print(answer)


import string
rock_count = int(input())
holder = {}
for _ in range(rock_count):
	rock = input()
	for l in string.ascii_lowercase:
		if rock.find(l) != -1:
			try:
				holder[l] += 1
			except:
				holder[l] = 1
count = 0
for gem in holder:
	if holder[gem] == rock_count:
		count += 1
print(count)


def f(t1, t2):
	x = []
	y = []
	for i in t1:
		if i in x or i in y:
			continue
		elif i in t2:
			x.append(i)
			y.append(i)
		else:
			y.append(i)
	return x

def g(l):
	if len(l) == 1:
		return l
	else:
		x = l[0]
		i = 1
		while i < len(l):
			x = f(x, l[i])
			i += 1
	return len(x)
n = int(input())
l = []
for i in range(n):
	t = input()
	l.append(str(t))
print(g(l))


N = int(input())
gem_elements = None
for _ in range(N):
	composition = input()
	elements = set(composition)
	if gem_elements is None:
		gem_elements = elements
	else:
		gem_elements = gem_elements.intersection(elements)
print(len(gem_elements))


def union(x, y):
	answer = []
	for i in range(len(x)):
		item = x[i]
		if item in y and item not in answer:
			answer.append(item)
	return answer
samples = int(input())
elements = list(input())
elements = union(elements, elements)
for sample in range(samples - 1):
	find = list(input())
	elements = union(elements, find)
print(len(elements))


a = int(input())
x = []
for i in range(a):
	x.append(set(input()))
m = set(x[0])
for j in range(1, len(x)):
	m = m.intersection(x[j])
print(len(m))


N = int(input())
gems = []
for i in range(N):
	gems.append(set(input()))
result = set(gems[0])
for i in gems:
	result &= i
print(len(result))


gems = int(input())
elems = set(input())
for i in range(0, gems - 1):
	elems = elems.intersection(set(input()))
print(len(elems))


N = int(input())
result = set(input().strip())
for _ in range(N - 1):
	result = result.intersection(input().strip())
print(len(result))


import sys
N = int(sys.stdin.readline())
elements = dict()
for i in range(N):
	rock = sys.stdin.readline()
	for element in rock:
		if element != '\n':
			if element not in elements:
				elements[element] = set()
			elements[element] |= set([i])
gem_elements = 0
for element in elements:
	flag = True
	for rock in range(N):
		if rock not in elements[element]:
			flag = False
			break
	if flag:
		gem_elements += 1
print(gem_elements)


x = int(input())
y = ''
count = ''
for i in range(x):
	y = y + input() + ','
z = y.split(',')
del z[len(z) - 1]
j = []
for i in range(len(z)):
	j = j + [list(z[i])]
for x in j[0]:
	for x1 in range(len(j) - 1):
		if x in j[x1 + 1]:
			flag = 1
		else:
			flag = 0
			break
	if flag == 1:
		if x not in count:
			count += x
print(len(count))


T = int(input())
s = set(input())
for i in range(T - 1):
	s &= set(input())
print(len(s))


n = int(input())
stones = [input() for i in range(n)]
gems = 'abcdefghijklmnopqrstuvwxyz'
gem = 0
for elem in gems:
	for rock in stones:
		if not elem in rock:
			break
	else:
		gem += 1
print(gem)


strs = []
for i in range(int(input())):
	strs.append(set(input()))
print(len(set.intersection(*strs)))


def main():
	total_rocks = int(input())
	gem_element = set(input())
	for _ in range(total_rocks - 1):
		gem_element.intersection_update(set(input()))
	print(len(gem_element))
main()


n = int(input())
l1 = list(input())
for i in range(n - 1):
	l2 = list(input())
	l1 = list(set(l1).intersection(set(l2)))
print(len(l1))


rock_count = int(input())
rock_collection = []
for i in range(rock_count):
	rock = input()
	rock_collection.insert(0, set(tuple(map(lambda x: x, rock))))
rc = rock_collection[1:len(rock_collection)]
print(len(rock_collection[0].intersection(*rc)))


num_rocks = int(input())
elements = {}
for i in range(num_rocks):
	element_set = set()
	for element in input():
		element_set.add(element)
	for element in element_set:
		if element in elements:
			elements[element] += 1
		else:
			elements[element] = 1
num_gems = 0
for element in elements:
	if elements[element] == num_rocks:
		num_gems += 1
print(num_gems)


def compute(gem, rock):
	for c in gem:
		if c not in rock:
			gem.remove(c)
			gem = compute(gem, rock)
	return gem
n = int(input())
gem_list = list(input())
gem_list = sorted(set(gem_list), key=gem_list.index)
for i in range(1, n):
	rock = list(input())
	gem_list = compute(gem_list, rock)
print(len(gem_list))


def main():
	N = int(input())
	gems = []
	for i in range(N):
		if i == 0:
			gems = set(list(input()))
		else:
			gems = set([x for x in list(input()) if x in gems])
	print(len(gems))
main()


N = int(input())
final_letters = set('qwertyuiopasdfghjklzxcvbnm')
for _ in range(N):
	line = input()
	letters = set(line)
	final_letters = final_letters & letters
print(len(final_letters))


import sys, math, copy
data = sys.stdin.readlines()
nRocks = int(data[0])
rocks = data[1:]
k = 0
for e in 'abcdefghijklmnopqrstuvwxyz':
	for r in rocks:
		if e not in r:
			break
	else:
		k += 1
print(k)


import sys
data = sys.stdin.readlines()
num_stones = int(data[0])
elem_count = [(0, 0) for i in range(26)]
for i in range(1, num_stones + 1):
	for j in data[i]:
		if ord(j) >= 97 and elem_count[ord(j) - 97][1] < i:
			elem_count[ord(j) - 97] = (elem_count[ord(j) - 97][0] + 1, i)
gem_elem = 0
for i in range(26):
	if elem_count[i][0] == num_stones:
		gem_elem += 1
print(gem_elem)


import sys, re
gems = {}

def main(item):
	gs = list(item)
	for g in gs:
		if gems.get(g) is None:
			gems[g] = g
		else:
			gems[g] = gems.get(g) + g
	for (k, v) in gems.items():
		if not re.search(gems.get(k), '\\|$'):
			gems[k] += '|'
count = 0
stuff = sys.stdin
rocks = int(stuff.readline())
out = stuff.readlines()
for item in out:
	main(item.strip())
for (k, v) in gems.items():
	if len(v.split('|')) > rocks:
		count += 1
print(count)


N = int(input()) - 1
elements = set(input())
while N > 0:
	elements &= set(input())
	N -= 1
print(len(elements))


from string import ascii_lowercase as low
out = low
n = int(input())
for i in range(n):
	curr = input()
	out = list(filter(lambda x: True if x in curr else False, out))
print(len(out))


n = int(input())
rocks = [input() for i in range(n)]
elements = list()
for rock in rocks:
	elements += list(rock)
elements = set(elements)
gems = list()
for element in elements:
	is_gem = True
	for rock in rocks:
		is_gem = is_gem and element in list(rock)
	if is_gem:
		gems.append(element)
print(len(gems))


ges = None
for i in range(int(input())):
	if ges is None:
		ges = set(input())
	else:
		ges &= set(input())
print(len(ges))


import sys
count = dict()
flag = dict()
N = int(sys.stdin.readline())
for i in range(0, N):
	flag.clear()
	s = sys.stdin.readline().strip()
	for c in s:
		if c in flag:
			continue
		if c in count:
			count[c] = count[c] + 1
		else:
			count[c] = 1
		flag[c] = 1
j = 0
for i in count.keys():
	if count[i] == N:
		j = j + 1
print(j)


import sys

def getAllTheLetters(begin='a', end='z'):
	beginNum = ord(begin)
	endNum = ord(begin)
	returnStr = ''
	for number in range(beginNum, endNum + 1):
		returnStr += chr(number)

def strIntersection(s1, s2):
	out = ''
	for c in s1:
		if c in s2 and (not c in out):
			out += c
	return out
N = int(sys.stdin.readline())
gems = 'abcdefghijklmnopqrstuvwxyz'
for n in range(N):
	stone = sys.stdin.readline()
	gems = strIntersection(stone, gems)
print(len(gems))


_N = int(input())
gem_elements = list()
rocks = list()

def in_rock(element, rock):
	for e in list(rock):
		if e is element:
			return True
	return False
for i in range(0, _N):
	rocks.append(input())
for rock in rocks:
	for element in rock:
		x = True
		for r in rocks:
			x = x & in_rock(element, r)
		if x and element not in gem_elements:
			gem_elements.append(element)
print(str(len(gem_elements)))


n = int(input())
a = set(list(input()))
for _ in range(0, n - 1):
	b = set(list(input()))
	a = a & b
print(len(a))


checked = []
compositions = []
gemStones = 0
gems = int(input().strip())
for gem in range(gems):
	compositions.append(input().strip())
for c in compositions[0]:
	if c in checked:
		continue
	else:
		checked.append(c)
		contains = True
		for composition in compositions[1:]:
			if not c in composition:
				contains = False
		if contains:
			gemStones += 1
print(gemStones)


words = int(input())
word = []
gem = []
notgem = []
for i in range(words):
	word.append(input())
for i in word:
	for char in i:
		if char not in gem and char not in notgem:
			for j in word:
				if j.find(char) == -1:
					notgem.append(char)
					break
			else:
				gem.append(char)
print(len(gem))


t = int(input())
assert t <= 100 and t >= 1
a = set(input())
for i in range(t - 1):
	b = set(input())
	a = a.intersection(b)
print(len(a))


number = int(input())
count = 0
arr = []
for i in range(number):
	arr.append(input())
ch_array = []
for ch in arr[0]:
	ch_count = 1
	for string in arr[1:]:
		if ch in string and ch not in ch_array:
			ch_count += 1
			continue
		else:
			break
	ch_array.append(ch)
	if ch_count == number:
		count += 1
print(count)


from collections import Counter
n = int(input())
r = Counter()
for _ in range(n):
	r.update(Counter(input()).keys())
print(len([0 for (_, c) in r.items() if c == n]))


N = int(input())
gems = set('qwertyuiopasdfghjklzxcvbnm')
for _ in range(N):
	gems = gems & set(input())
print(len(list(gems)))


t = int(input())
word = input()
uniq = list(set(word))
uniq.sort()
for i in range(t - 1):
	tmp_uniq = []
	tmp_word = input()
	for j in uniq:
		if j in tmp_word:
			tmp_uniq.append(j)
	uniq = tmp_uniq
print(len(uniq))


n = int(input())
l = []
for i in range(n):
	l.append(input())
count = 0
s = set(l[0])
for i in range(1, n):
	s = s & set(l[i])
print(len(s))


n = int(input())
input_str = list(input())
test_str = list('')
for lett in input_str:
	if lett not in test_str:
		test_str.append(lett)
ToRemove = list('')
for _ in range(n - 1):
	str_in = input()
	for lett in test_str:
		if lett not in str_in and lett not in ToRemove:
			ToRemove.append(lett)
for lett in ToRemove:
	if lett in test_str:
		for _ in range(test_str.count(lett)):
			test_str.remove(lett)
print(len(test_str))


from string import ascii_lowercase
chars = ascii_lowercase
n = input()
R = []
c = 0
for i in range(int(n)):
	R.append(input())
for x in chars:
	present = True
	for r in R:
		if x not in r:
			present = False
	if present:
		c += 1
print(c)


letters_alphabet = 26
rock_element_list = list()
is_gem_element = False
number_of_gem_element = 0
n = int(input())
while n > 0:
	rock_element_list.append(input())
	n = n - 1
ascii_value = 97
size_list = len(rock_element_list)
i = 0
while ascii_value < 123:
	while i < size_list:
		if chr(ascii_value) in rock_element_list[i]:
			i += 1
			is_gem_element = True
		else:
			is_gem_element = False
			break
	if is_gem_element == True:
		number_of_gem_element += 1
	i = 0
	ascii_value += 1
print(number_of_gem_element)


setlist = []
T = int(input())
for x in range(0, T):
	a = set(list(input()))
	setlist.append(a)
	u = set.intersection(*setlist)
print(len(u))


a = int(input())
thing = []
for x in range(a):
	thing.append(input())
b = set(list(thing[0]))
for x in thing:
	b = b.intersection(set(list(x)))
print(len(b))


n = int(input())
b = set(input())
for i in range(n - 1):
	a = set(list(input()))
	a = a.intersection(b)
	b = a
print(len(a))


n = int(input())
a = set(list(input()))
for i in range(n - 1):
	b = set(list(input()))
	b = b.intersection(a)
	a = b
print(len(a))


case_count = int(input())
elements = set(input())
for i in range(case_count - 1):
	case_elements = set(input())
	elements = elements & case_elements
print(len(elements))


N = int(input())
output = set(input())
for _ in range(N - 1):
	output = output.intersection(set(input()))
print(len(output))


n = int(input())
gem = []
for letter in input():
	if letter not in gem:
		gem.append(letter)
for i in range(n - 1):
	inp = input()
	rem = []
	for l in gem:
		if l not in inp:
			rem.append(l)
	for l in rem:
		gem.remove(l)
print(len(gem))


def solveMeFirst(A):
	items = set()
	for y in A[0]:
		items.add(y)
	for x in A:
		i2 = set()
		for q in x:
			i2.add(q)
		items = items.intersection(i2)
	return len(items)
i = int(input())
j = 0
arr = []
while j < i:
	j += 1
	arr.append(input())
print(solveMeFirst(arr))