strr = input()
word = input()
count = 0
res = 0
word = set(word)
for i in word:
    for j in strr.lower():
        if i == j:
            count += 1
res = count % len(word)
print(res)

ab4122cc84a4ca4e9a3289d50aab228cad2031e7
<mask token>

<mask token>
for i in word:
    for j in strr.lower():
        if i == j:
            count += 1
<mask token>
print(res)

strr = input()
word = input()
count = 0
res = 0
word = set(word)
for i in word:
    for j in strr.lower():
        if i == j:
            count += 1
res = count % len(word)
print(res)
