/* 
   10022 ??則???????属???????????????\???????????????n?????蔵???
   "??則????????即?属???????????????\?????????"?????????????????????????????????????????????
*/
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    solve();
    }
    static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    }
} import java.util.*; util.* java public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    solve();
    }
    static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    }
} Main static Scanner kbd = new Scanner(System.in); kbd new Scanner(System.in) public  static void main(String[] args){
    solve();
    } main {
    solve();
    } solve() solve String[] args args static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    } solve {
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    } String n = kbd.next(); n kbd.next() kbd.next kbd int ans = 0; ans 0 while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    } kbd.hasNext() kbd.hasNext kbd {
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    } String s = kbd.next(); s kbd.next() kbd.next kbd if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        } s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" {
        System.out.println(ans);
        } System.out.println(ans) System.out.println System.out System System.out ans {
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        } if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        } n.compareToIgnoreCase(s)==0 n.compareToIgnoreCase(s) n.compareToIgnoreCase n s 0 { // ????????????????????????????????????
            ans++;
        } ans++ ans public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    solve();
    }
    static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    }
} public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    solve();
    }
    static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    }
} Main
/* 
   10022 ??則???????属???????????????\???????????????n?????蔵???
   "??則????????即?属???????????????\?????????"?????????????????????????????????????????????
*/
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    solve();
    }
    static void solve(){
    String n = kbd.next();
    int ans = 0;
    while(kbd.hasNext()){
        String s = kbd.next();
        if(s.equals("END_OF_TEXT")){
        System.out.println(ans);
        }
        else{
        if(n.compareToIgnoreCase(s)==0){ // ????????????????????????????????????
            ans++;
        }
        }
    }
    }
}