import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



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

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

} Main public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	} main {

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	} BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		} catch(IOException e){
			System.out.print(e);
		} IOException e {
			System.out.print(e);
		} System.out.print(e) System.out.print System.out System System.out e {
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		} String W=reader.readLine().toLowerCase(); W reader.readLine().toLowerCase() reader.readLine().toLowerCase reader.readLine() reader.readLine reader String text=""; text "" while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		} true {
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		} String p=reader.readLine(); p reader.readLine() reader.readLine reader if(p.equals("END_OF_TEXT"))break; p.equals("END_OF_TEXT") p.equals p "END_OF_TEXT" break; text+=" "+p.toLowerCase() text " "+p.toLowerCase() " " p.toLowerCase() p.toLowerCase p text=text.replaceAll("\\.", " ") text text.replaceAll("\\.", " ") text.replaceAll text "\\." " " text=text.replaceAll("\\n", " ") text text.replaceAll("\\n", " ") text.replaceAll text "\\n" " " String[] array_text=text.split(" "); array_text text.split(" ") text.split text " " int count=0; count 0 for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		} int i=0; int i=0; i 0 i<array_text.length i array_text.length array_text array_text.length i++ i++ i {
			if(array_text[i].equals(W)){
				count++;
			}
		} {
			if(array_text[i].equals(W)){
				count++;
			}
		} if(array_text[i].equals(W)){
				count++;
			} array_text[i].equals(W) array_text[i].equals array_text[i] array_text i W {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

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

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



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

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

}