#include <iostream>
#include <sstream>
#include <vector>
#include <string>
using namespace std;
int main() {
string sentence, word;
getline(cin, sentence);
cin >> word;
if (!sentence.empty() && sentence[sentence.size() - 1] == '.') {
sentence.erase(sentence.size() - 1);
}
stringstream ss(sentence);
vector<string> words;
string temp;
while (ss >> temp) {
words.push_back(temp);
}
int position = -1;
for (size_t i = 0; i < words.size(); ++i) {
if (words[i] == word) {
position = i + 1;
break;
}
}
if (position != -1) {
cout << position << endl;
} else {
int totalChars = 0;
for (size_t i = 0; i < words.size(); ++i) {
totalChars += words[i].size();
}
cout << totalChars << endl;
}
return 0;
}
/**************************************************************
Problem: 1012
User: lidongbo
Language: C++
Result: Compile Error
****************************************************************/