import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
} import java.util.InputMismatchException; InputMismatchException java.util import java.util.Scanner; Scanner java.util public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
} Main @SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		} main {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String str1=scan.next().toUpperCase(); str1 scan.next().toUpperCase() scan.next().toUpperCase scan.next() scan.next scan int count=0; count 0 try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		} catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		} InputMismatchException e {
			System.out.println("入力しなおしてください");
		} System.out.println("入力しなおしてください") System.out.println System.out System System.out "入力しなおしてください" {
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		} while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			} true {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			} String str=scan.next(); str scan.next() scan.next scan if(str.toUpperCase().equals(str1)) {
					count++;
				} str.toUpperCase().equals(str1) str.toUpperCase().equals str.toUpperCase() str.toUpperCase str str1 {
					count++;
				} count++ count if(str.equals("END_OF_TEXT")){
					break;
				} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
					break;
				} break; System.out.println(count) System.out.println System.out System System.out count scan.close() scan.close scan String[] args args public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
} public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
} Main
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
}
