import (
    "fmt"
    "bufio"
    "os"
    "strings"
)
func main() {
    reader := bufio.NewReader(os.Stdin)
    str, _ := reader.ReadString('\n')
    s := strings.ToLower(str)
    ch, _ := reader.ReadString('\n')
    c := strings.ToLower(ch)
    
    hash := map[byte]int{}
    for i := 0; i < len(s); i++ {
        b := byte(s[i])
        hash[b]++
    }
    ce := byte(c[0])
    fmt.Println(hash[ce])
}