import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
} Main public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	} main {
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	} Scanner scan = null; scan null try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		} {
			if(scan!=null)scan.close();
		} if(scan!=null)scan.close(); scan!=null scan null scan.close() scan.close scan {
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		} scan = new Scanner(System.in) scan new Scanner(System.in) String str; str String text = scan.next(); text scan.next() scan.next scan int counter = 0; counter 0 while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			} !(str = scan.next()).equals("END_OF_TEXT") (str = scan.next()).equals("END_OF_TEXT") (str = scan.next()).equals (str = scan.next()) str scan.next() scan.next scan "END_OF_TEXT" {
				if(text.equals(str.toLowerCase()))counter++;
			} if(text.equals(str.toLowerCase()))counter++; text.equals(str.toLowerCase()) text.equals text str.toLowerCase() str.toLowerCase str counter++ counter System.out.println(counter) System.out.println System.out System System.out counter String[] args args public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
}