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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}System.out.println(count);
		}
		
		} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}System.out.println(count);
		} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}System.out.println(count);
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str String x=br.readLine(); x br.readLine() br.readLine br int count=0; count 0 for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		} ; (str=br.readLine())!=null (str=br.readLine()) str br.readLine() br.readLine br null {
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		} {
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		} String[] stg=str.split(" "); stg str.split(" ") str.split str " " for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			} String i stg {
				if(i.equalsIgnoreCase(x))count++;
			} {
				if(i.equalsIgnoreCase(x))count++;
			} if(i.equalsIgnoreCase(x))count++; i.equalsIgnoreCase(x) i.equalsIgnoreCase i x count++ count 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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;(str=br.readLine())!=null;){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}System.out.println(count);
		}
		
		}