int main() {
    char s[1000] = { 0 };
    gets(s);
    int len = strlen(s);
    char ch = getchar();
    if (ch >= 'A' && ch <= 'Z')
        ch = ch + 32;
    int count = 0;
    for (int i = 0; i < len; i++) {
        if (s[i] >= 'A' && s[i] <= 'Z') {
            s[i] = s[i] + 32;
        }
        if (s[i] == ch)
            count++;
    }
    printf("%d", count);
    return 0;
}