#include <iostream>
#include <string>
using namespace std;

const int CASE_DIFF = 'a' - 'A';

int isBinaryWord(const string &word) {
    const int lenWord = (int)word.size();
    char fstLetter = word[0], lastLetter = '*';
    for (int i = 1; i < lenWord; ++i) {
        if (word[i] != fstLetter && lastLetter == '*') {
        	lastLetter = word[i];
        }
        if (lastLetter != word[i] && fstLetter != word[i]) {
            return 0;
        }
    }
    return 1;
}

int main() {
    string text;
    int cntBinaryWords = 0;
    while (getline(cin, text)) {
        const int lenText = (int)text.size();
        string currWord;
        for (int i = 0; i <= lenText; ++i) {
            if (isalpha(text[i])) {
                if (text[i] >= 'A' && text[i] <= 'Z') {
                    text[i] += CASE_DIFF;
                }
                currWord += text[i];
            } else if (!currWord.empty()) {
                cntBinaryWords += isBinaryWord(currWord);
                currWord.clear();
            }
        }
    }
    cout << cntBinaryWords;
    return 0;
}
