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


public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    }
} 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) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W  = br.readLine().toLowerCase(); W br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br String T; T int count = 0; count 0 while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        } !(T=br.readLine()).equals("END_OF_TEXT") (T=br.readLine()).equals("END_OF_TEXT") (T=br.readLine()).equals (T=br.readLine()) T br.readLine() br.readLine br "END_OF_TEXT" {
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        } String TList[] = T.toLowerCase().split(" "); TList T.toLowerCase().split(" ") T.toLowerCase().split T.toLowerCase() T.toLowerCase T " " for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	} int i=0; int i=0; i 0 i<TList.length i TList.length TList TList.length i++ i++ i {
        		if(TList[i].equals(W)){
        			count++;
        		}
        	} {
        		if(TList[i].equals(W)){
        			count++;
        		}
        	} if(TList[i].equals(W)){
        			count++;
        		} TList[i].equals(W) TList[i].equals TList[i] TList 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) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W  = br.readLine().toLowerCase();
        String T;
        int count = 0;
        while(!(T=br.readLine()).equals("END_OF_TEXT")){
        	String TList[] = T.toLowerCase().split(" ");
        	for(int i=0;i<TList.length;i++){
        		if(TList[i].equals(W)){
        			count++;
        		}
        	}

        }
        System.out.println(count);
    }
}