import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc s.toLowerCase() s.toLowerCase s int n=s.length(); n s.length() s.length s int ans=0; ans 0 while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        } true {
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        } String t=sc.nextLine(); t sc.nextLine() sc.nextLine sc if(t.equals("END_OF_TEXT")) break; t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            } String u t.toLowerCase().split(" ") t.toLowerCase().split t.toLowerCase() t.toLowerCase t " " {
                if(s.equals(u)) ans++;
            } {
                if(s.equals(u)) ans++;
            } if(s.equals(u)) ans++; s.equals(u) s.equals s u ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s.toLowerCase();
        int n=s.length();
        int ans=0;
        while(true){
            String t=sc.nextLine();
            if(t.equals("END_OF_TEXT")) break;
            for(String u:t.toLowerCase().split(" ")){
                if(s.equals(u)) ans++;
            }
        }
        System.out.println(ans);
    }
}
