import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    } main {
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.next().toLowerCase(); W scan.next().toLowerCase() scan.next().toLowerCase scan.next() scan.next scan int count = 0; count 0 int sys_count = 0; sys_count 0 while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        } true {

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        } sys_count++ sys_count String T = scan.next(); T scan.next() scan.next scan if(T.equals("END_OF_TEXT")){
                break;
            } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
                break;
            } break; if(W.equals(T.toLowerCase())){
                ++count;
            } W.equals(T.toLowerCase()) W.equals W T.toLowerCase() T.toLowerCase T {
                ++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 scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    }
} Main
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

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