#include <iostream>
#include <string>
#include <sstream>

int main() {
    std::string sentence, target;
    // 读取整行句子
    std::getline(std::cin, sentence);
    // 读取目标单词
    std::cin >> target;

    std::istringstream iss(sentence);
    std::string word;
    int wordCount = 0;
    int charCount = 0;
    bool found = false;

    while (iss >> word) {
        // 去除单词末尾的句号
        if (word.back() == '.') {
            word.pop_back();
        }
        wordCount++;
        charCount += word.length();

        if (!found && word == target) {
            std::cout << wordCount << std::endl;
            found = true;
        }
    }

    if (!found) {
        std::cout << charCount << std::endl;
    }

    return 0;
}
    
/**************************************************************
	Problem: 1012
	User: fuyijun
	Language: C++
	Result: Accepted
	Time:7 ms
	Memory:2136 kb
****************************************************************/