

import java.util.Scanner;

public class Main {
	public static void main(String []args){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String []args){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	}
} Main public static void main(String []args){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	} main {
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count =0; count 0 String W=""; W "" String word =""; word "" W = sc.next() W sc.next() sc.next sc while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		} true {
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		} word = sc.next() word sc.next() sc.next sc if(word.equals("END_OF_TEXT")){
				break;
			} word.equals("END_OF_TEXT") word.equals word "END_OF_TEXT" {
				break;
			} break; if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			} W.equalsIgnoreCase(word) W.equalsIgnoreCase W word {
				//W?????????????????°count
				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){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	}
} public class Main {
	public static void main(String []args){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	}
} Main


import java.util.Scanner;

public class Main {
	public static void main(String []args){
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int count =0;
		String W="";
		String word ="";
		//??????????????? W
		W = sc.next();
		while(true){
			//?????????????????? ???????????????
			word = sc.next();

			if(word.equals("END_OF_TEXT")){
				break;
			}
			//??????W????????????????????????????????????
			if(W.equalsIgnoreCase(word)){
				//W?????????????????°count
				count ++;
			}
		}
			//??¨???
			System.out.println(count);
	}
}