Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not.  Her King requested for her help in mining precious stones, so she has told him which all stones are jewels and which are not. Given her description, your task is  to count the number of jewel stones. 

More formally, you're given a string J composed of latin characters where each character is a jewel. You're also given a string S composed of latin characters where each character is a mined stone. You have to find out how many characters of S are in J as well. 

-----Input-----

First line contains an integer T denoting the number of test cases. Then follow T test cases. Each test case consists of two lines, each of which contains a string composed of English lower case and upper characters. First of these is the jewel string J and the second one is stone string S. 
You can assume that  1 <= T <= 100, 1 <= |J|, |S| <= 100


-----Output-----
Output for each test case, a single integer, the number of jewels mined. 

-----Example-----
Input:
4
abc
abcdef
aA
abAZ
aaa
a
what
none

Output:
3
2
1
0

Difficulty: interview

Starter code:

Solutions:
n = int(input())
for i in range(n):
 count = 0
 k = input()
 x = list(k)
 kk = input()
 y = list(kk)
 for j in y:
  for jj in x:
   if(j==jj):
    count = count+1
    break
 print(count)

for _t in range(int(input())):
 J = set(list(input().strip()))
 print(sum(1 for x in input() if x in J))

T=int(input())
for i in range(1, T+1):
 J=input()
 S=input()
 count=0
 for letter in S:
  if(letter in J):
   count+=1
 print(count)


# code chef may2012  stones.py


t = int(input())
for t1 in range(t):
 j = input().strip()
 s = input().strip()
 answer = 0
 for c in s:
  if c in j:
   answer +=1
 print(answer)


ile = eval(input())
while ile:
 suma = 0
 lista = input()
 jeweled = input()
 for znak in jeweled:
  if znak in lista:
   suma+=1
 print(suma)
 ile-=1

'''
Created on 6 mai 2012

@author: Quentin
'''
import sys, re

def readInput(stream):
 T = int(stream.readline())
 JSs = []
 for Tit in range(T) :
  J = re.sub("[\n\s]*","",stream.readline())
  S = re.sub("[\n\s]*","",stream.readline())
  JSs.append((J,S))
 return JSs

def compute(JSs):
 for J, S in JSs :
  count = 0
  for char in S :
   if J.find(char) != -1 :
    count += 1
  print(count)

def __starting_point():
 JSs = readInput(sys.stdin)
 compute(JSs)
__starting_point()

a = (int)(input())

for i in range(a):
 total = 0
 str1 = input()
 str2 = input()
 str1 = set(str1)
#   str2 = set(str2)    
 for a in str1:
  for b in str2:
   if a == b:
    total = total+ 1
 print(total)

n=int(input())
for i in range(0,n):
 s=0
 r1=input().strip()
 r2=input().strip()
 for i in r2:
  if i in r1:
   s+=1
 print(s)

def process(first, second):
 dist1 = {}
 dist2 = {}
 for s in first:
  dist1[s] = 1
 ret = 0
 for s in second:
  if s in dist1:
   ret = ret + 1

 print(ret)

def __starting_point():
 cases = int(input())
 for i in range(cases):
  first = input()
  second = input()

  process(first, second)

__starting_point()

t=(int)(input())
while t>0:
 t-=1
 c=0
 j=input()
 s=input()
 n=j.__len__()
 m=s.__len__()
 l=int(m)
 p=int(n)
 for i in range(l):
  for k in range(p):
   if s[i]==j[k]:
    c+=1
    break
 print(c)

n=int(input())
for i in range(0,n):
 s=0
 r1=input().strip()
 r2=input().strip()
 for i in r2:
  if i in r1:
   s+=1
 print(s)


for case in range(int(input())):
 jewels = set([])
 for char in input().rstrip("\n"):
  jewels.add(char)
 
 count = 0
 for char in input().rstrip("\n"):
  if char in jewels:
   count += 1
 print(count)

tc = int(input())
for itercnt in range(tc):
 str1 = input()
 str2 = input()
 cnt = 0
 for x in str2:
  for y in str1:
   if (x == y): 
    cnt+=1
    break
 print(cnt)

#Jewels And Stones
def common(s1,s2):
 n=0
 done=[]
 for i in s1:
  if i in done:
    continue
  for j in s2:
   if i==j:
    n+=1
  done+=[i]
 return n
t=int(input())
for i in range(t):
 s1=str(input())
 s2=str(input())
 print(common(s1,s2))


# Jewels.py
# Code Chef Problem: Jewels and Stones
#   http://www.codechef.com/MAY12/problems/STONES
#   May Long Challenge 2012
# Benjamin Johnson
# May 4 2012 
# Lessons Learned:

import sys,time,math

#Use the test file when testing
#testInputFile = open("test.in","r")

#Get input here
testCases = int(sys.stdin.readline())
#testCases = int(testInputFile.readline())

for i in range(testCases):
 count = 0
 jewels = {}
 #jewelsLine = testInputFile.readline().strip()
 jewelsLine = sys.stdin.readline().strip()
 for char in jewelsLine:
  if char in jewels:
   jewels[char] += 1
  else:
   jewels[char] = 1
 #stonesLine = testInputFile.readline().strip()
 stonesLine = sys.stdin.readline().strip()
 for stone in stonesLine:
  if stone in jewels:
   if jewels[stone] > 0:
    #jewels[stone] -= 1
    count += 1
 sys.stdout.write("%d\n"%count)

#testInputFile.close()


def __starting_point():
 t = int(input().strip())
 for test in range(t):
  s1 = input().strip()
  d1 = {}
  for i in s1:
   if i in d1:
    d1[i] += 1
   else:
    d1[i] = 1
  s2 = input().strip()
  ans = 0
  for i in s2:
   if i in d1:
    d1[i] -= 1
    ans += 1
  print(ans)
  

__starting_point()

from sys import *
t=eval(input())
for i in range(t):
 j=input()
 s=input()
 ans=0
 for k in range(len(s)):
  if s[k] in j:
   ans+=1
 print(ans)
return

t = int(input())
while t > 0:
 s = set(input())
 ans = 0
 for c in input():
  if c in s:
   ans += 1
 print(ans)
 t -= 1


def main():

 t = int(input())

 # enter cases
 for i in range(t):
  a = str(input())
  b = str(input())
  checkJewellery(a, b)

def checkJewellery(a, b):
 count = 0
 for s in b:
  if s in a:
   count = count + 1
 print(count)

#===============================================================================

def __starting_point():
 main()

__starting_point()

#!/usr/bin/env python
#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      dvdreddy
#
# Created:     05/03/2012
# Copyright:   (c) dvdreddy 2012
# Licence:     <your licence>
#-------------------------------------------------------------------------------



def toint(s): return int(s)
def tofloat(s): return float(s)

def get_int():
 s=input()
 return int(s)

def main():
 t=get_int()
 while t:
  j=input()
  s=input()

  a=[0]*256
  for i in j:
   a[ord(i)]=1
  res=0
  for i in s:
   res+=a[ord(i)]
  print(res)
  t-=1
 pass

def __starting_point():
 main()

__starting_point()