import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

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

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

  }
} Main public static void main(String[] arg){

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

  } main {

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

  } int count = 0; count 0 Scanner in = new Scanner(System.in); in new Scanner(System.in) String w = in.nextLine(); w in.nextLine() in.nextLine in w = w.toLowerCase() w w.toLowerCase() w.toLowerCase w while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    } true {
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    } String t = in.nextLine(); t in.nextLine() in.nextLine in if(t.equals("END_OF_TEXT")) break; t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t String [] words = t.split(" ",0); words t.split(" ",0) t.split t " " 0 for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++; int i=0; int i=0; i 0 i<words.length i words.length words words.length i++ i++ i if(w.equals(words[i]))
                count++; if(w.equals(words[i]))
                count++; w.equals(words[i]) w.equals w words[i] words i count++ count System.out.println(count) System.out.println System.out System System.out count String[] arg arg
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

  }
}