import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main{
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new FileReader("sample.txt"));
						
		String x=sc.next();
		
		String str;
		int count=0;
		for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			}sc.close();
			
			System.out.println(count);
		}
		
		} import java.io.BufferedReader; BufferedReader java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new FileReader("sample.txt"));
						
		String x=sc.next();
		
		String str;
		int count=0;
		for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			}sc.close();
			
			System.out.println(count);
		}
		
		} Main public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new FileReader("sample.txt"));
						
		String x=sc.next();
		
		String str;
		int count=0;
		for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			}sc.close();
			
			System.out.println(count);
		} main {

		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new FileReader("sample.txt"));
						
		String x=sc.next();
		
		String str;
		int count=0;
		for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			}sc.close();
			
			System.out.println(count);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x=sc.next(); x sc.next() sc.next sc String str; str int count=0; count 0 for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			} ; !((str=sc.next()).equals("END_OF_TEXT")) ((str=sc.next()).equals("END_OF_TEXT")) (str=sc.next()).equals (str=sc.next()) str sc.next() sc.next sc "END_OF_TEXT" {
			
			if((str.equalsIgnoreCase(x)))count++;
			} {
			
			if((str.equalsIgnoreCase(x)))count++;
			} if((str.equalsIgnoreCase(x)))count++; (str.equalsIgnoreCase(x)) str.equalsIgnoreCase str x count++ count sc.close() sc.close sc System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main{
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new FileReader("sample.txt"));
						
		String x=sc.next();
		
		String str;
		int count=0;
		for(;!((str=sc.next()).equals("END_OF_TEXT"));){
			
			if((str.equalsIgnoreCase(x)))count++;
			}sc.close();
			
			System.out.println(count);
		}
		
		}