#K84172. Common Characters Count
Common Characters Count
Common Characters Count
Given two strings A and B, your task is to compute the number of distinct characters that appear in both strings. In other words, if we denote by \(S(A)\) the set of characters in string A and by \(S(B)\) the set of characters in string B, you need to find \(|S(A) \cap S(B)|\). For example, if A = "hello" and B = "world", then \(S(A) = \{h,e,l,o\}\), \(S(B) = \{w,o,r,l,d\}\) and the intersection is \(\{l, o\}\), so the answer is 2.
Note: The comparisons are case-sensitive, meaning that uppercase and lowercase letters are considered distinct.
inputFormat
The first line of input contains an integer T (the number of test cases). Each of the following test cases consists of two lines:
- The first line contains the first string A.
- The second line contains the second string B.
It is guaranteed that each string is non-empty and consists of printable ASCII characters.
outputFormat
For each test case, output a single line containing one integer: the number of distinct characters that appear in both A and B.
## sample2
hello
world
apple
pear
2
3
</p>