const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
//定义变量
let count = 0
let str = await readline(); // 读取第一行字符串
let c = await readline(); //读取第二次输入的特定字符
//判断特定的字符是数字还是英文字母
if(/[a-zA-Z]/.test(c)){
let lowc = c.toLowerCase() //小写
let upc = c.toUpperCase() //大写
//遍历去对比每个字符
for(let char of str){
if(char===lowc || char===upc){
count++;
}
}
}else if(/[0-9]/.test(c) ){
for(let char of str){
if(char=== c){
count++;
}
}
}
console.log(count)
}()