#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
vector<string> readWords() {
string line;
getline(cin, line);
stringstream ss(line);
vector<string> words;
string word;
while (ss >> word) {
words.push_back(word);
}
return words;
}
int main() {
vector<string> studentWords = readWords();
vector<string> correctWords = readWords();
int correctCount = 0;
for (size_t i = 0; i < studentWords.size(); i) {
if (studentWords[i] == correctWords[i]) {
correctCount;
}
}
cout << correctCount << endl;
return 0;
}