#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define CHAR_COUNT 1
/*
思路:输入的字符串、字符分为大小写,大写字符与小写字符相差32位,如果输入字符oneChar为大写,则将字符串字符strIn[i]大写与oneChar
比较或小写字符 与 字符oneChar+32进行比较;如果输入字符oneChar为小写,则将字符串字符strIn[i]小写与oneChar或
字符串字符strIn[i]大写与字符oneChar-32进行比较;
*/
#ifdef CHAR_COUNT
int OneCharCount(string strIn, char oneChar)
{
if(strIn.length() == 0) {
return 0;
}
int charCount = 0;
int strInLen = strIn.length();
if(oneChar >= 'A' && oneChar <= 'Z') {
for(int i = 0; i < strInLen; i++) {
if(strIn[i] == oneChar || strIn[i] -32 == oneChar) {
charCount++;
}
}
} else if(oneChar >= 'a' && oneChar <= 'z') {
for(int i = 0; i < strInLen; i++) {
if(strIn[i] + 32 == oneChar || strIn[i] == oneChar) {
charCount++;
}
}
} else {
for(int i = 0; i < strInLen; i++) {
if(strIn[i] == oneChar) {
charCount++;
}
}
}
return charCount;
}
#else
/*
思路:字符串的字符strIn[i]与输入字符oneChar比价,输入字符oneChar的大小写与strIn[i]比较
*/
int OneCharCount2(string strIn, char oneChar)
{
if(strIn.length() == 0) {
return 0;
}
int charCount = 0;
int strInLen = strIn.length();
if(oneChar >= 'A' && oneChar <= 'Z') {
for(int i = 0; i < strInLen; i++) {
if(toupper(strIn[i]) == oneChar || strIn[i] == oneChar) {
charCount++;
}
}
} else if(oneChar >= 'a' && oneChar <= 'z') {
for(int i = 0; i < strInLen; i++) {
if(tolower(strIn[i]) == oneChar || strIn[i] == oneChar) {
charCount++;
}
}
} else {
for(int i = 0; i < strInLen; i++) {
if(strIn[i] == oneChar) {
charCount++;
}
}
}
return charCount;
}
#endif
int main()
{
string strIn;
char oneChar;
getline(cin, strIn);
//oneChar = getchar();
cin>>oneChar;
#ifdef CHAR_COUNT
cout<<OneCharCount(strIn, oneChar)<<endl;
#else
cout<<OneCharCount2(strIn, oneChar)<<endl;
#endif
return 0;
}