import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tar = sc.next().toLowerCase();
		int count = 0;
		while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		}
		System.out.println(count);
	}
} import java.awt.*; awt.* java import java.awt.geom.*; geom.* java.awt import java.io.*; io.* java import java.util.*; util.* java class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tar = sc.next().toLowerCase();
		int count = 0;
		while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tar = sc.next().toLowerCase();
		int count = 0;
		while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String tar = sc.next().toLowerCase();
		int count = 0;
		while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String tar = sc.next().toLowerCase(); tar sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc int count = 0; count 0 while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		} true {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		} String tmp = sc.next(); tmp sc.next() sc.next sc if(tmp.equals("END_OF_TEXT")) break; tmp.equals("END_OF_TEXT") tmp.equals tmp "END_OF_TEXT" break; if(tar.equals(tmp.toLowerCase())) {
				count++;
			} tar.equals(tmp.toLowerCase()) tar.equals tar tmp.toLowerCase() tmp.toLowerCase tmp {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tar = sc.next().toLowerCase();
		int count = 0;
		while(true) {
			String tmp = sc.next();
			if(tmp.equals("END_OF_TEXT")) break;
			if(tar.equals(tmp.toLowerCase())) {
				count++;
			}
		}
		System.out.println(count);
	}
}