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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
} 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[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
} Main public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String INPUT = br.readLine(); INPUT br.readLine() br.readLine br int i = 0; i 0 int j = 0; j 0 String a; a while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		} (a = br.readLine()).equals("END_OF_TEXT")!=true (a = br.readLine()).equals("END_OF_TEXT") (a = br.readLine()).equals (a = br.readLine()) a br.readLine() br.readLine br "END_OF_TEXT" true {
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		} String[] input = a.split(" "); input a.split(" ") a.split a " " for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			} i=0 ; i=0 i 0 i<input.length i input.length input input.length i++ i++ i {
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			} {
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			} if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				} (INPUT.toUpperCase()).equals(input[i].toUpperCase()) (INPUT.toUpperCase()).equals (INPUT.toUpperCase()) INPUT.toUpperCase INPUT input[i].toUpperCase() input[i].toUpperCase input[i] input i {
					j++;
				} j++ j if( input[i].equals("END_OF_TEXT") ) break; input[i].equals("END_OF_TEXT") input[i].equals input[i] input i "END_OF_TEXT" break; System.out.println(Integer.toString(j)) System.out.println System.out System System.out Integer.toString(j) Integer.toString Integer j String[] age age public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
} public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
}