正则表达式:

const str = readline();
const key = readline();
(() => {
    const matchReg = new RegExp(`${key}`, 'ig')
    const matchRes = str.match(matchReg) || []
    console.log(matchRes.length)
})()