import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	}
} Main public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	} main {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	} int cnt=0; cnt 0 String comp_word = ""; comp_word "" String str = ""; str "" Scanner sc= new Scanner( System.in ); sc new Scanner( System.in ) comp_word = sc.next() comp_word sc.next() sc.next sc comp_word = comp_word.toLowerCase() comp_word comp_word.toLowerCase() comp_word.toLowerCase comp_word while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		} true {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		} str = sc.next() str sc.next() sc.next sc if ( str.equals("END_OF_TEXT") ) {
				break;
			} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
				break;
			} break; str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str if( str.equals(comp_word) ) {
				cnt++;
			} str.equals(comp_word) str.equals str comp_word {
				cnt++;
			} cnt++ cnt System.out.println( cnt ) System.out.println System.out System System.out cnt sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int cnt=0;
		String comp_word = "";
		String str = "";

		Scanner sc= new Scanner( System.in );

		comp_word = sc.next();
		comp_word = comp_word.toLowerCase();

		while( true ) {
			str = sc.next();


			if ( str.equals("END_OF_TEXT") ) {
				break;
			}

			str = str.toLowerCase();

			if( str.equals(comp_word) ) {
				cnt++;
			}

		}

		System.out.println( cnt );

		sc.close();
	}
}

