import java.util.*;

public class Main{
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    }
} Main public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    } main {

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.next().toLowerCase(); w sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc int cnt=0; cnt 0 while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    } true {
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    } String T = sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT"))    break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; String t = T.toLowerCase(); t T.toLowerCase() T.toLowerCase T if(t.equals(w))    cnt++; t.equals(w) t.equals t w cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    }
} public class Main{
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String w = sc.next().toLowerCase();
    

    int cnt=0;

    while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))    break;
        String t = T.toLowerCase();
        if(t.equals(w))    cnt++;
        
    }

    System.out.println(cnt);
    sc.close();
    }
}
