#include<bits/stdc++.h>
using namespace std;
int main() {
	string W;
	cin >> W;
	int ans = 0;
	string K;
	while (1) {
		cin >> K;
		if (K == "END_OF_TEXT")break;
		int n;
		n = K.size();
		for (int i = 0;i < n;i++) {
			if (K[i] >= 'A' && K[i] <= 'Z') {
				K[i] = K[i] + 32;
			}
		}
		if (K == W) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
