import java.util.Scanner;

public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
} Main public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    } solve {
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    } String t = null t null w = null; w null int c = 0; c 0 Scanner scan = new Scanner(System.in); scan new Scanner(System.in) w = scan.next() w scan.next() scan.next scan while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        } true {
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        } t = scan.next() t scan.next() scan.next scan if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            } t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; if(t.equalsIgnoreCase(w)){
                c++;
            } t.equalsIgnoreCase(w) t.equalsIgnoreCase t w {
                c++;
            } c++ c System.out.println(c) System.out.println System.out System System.out c public static void main(String[] args) {
        solve();
    } main {
        solve();
    } solve() solve String[] args args public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
} public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
} Main
import java.util.Scanner;

public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
}

