package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"unicode"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	// 读字符串 s
	s, _ := reader.ReadString('\n')
	s = strings.TrimSpace(s)

	// 读字符 c
	cLine, _ := reader.ReadString('\n')
	cLine = strings.TrimSpace(cLine)
	c := rune(cLine[0]) // 题目保证只有一个字符

	// 统计
	count := 0
	for _, r := range s {
		if unicode.IsLetter(c) {
			// c 是字母,忽略大小写
			if unicode.ToLower(r) == unicode.ToLower(c) {
				count++
			}
		} else {
			// c 是数字,精确匹配
			if r == c {
				count++
			}
		}
	}

	fmt.Println(count)
}