import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} import java.io.InputStreamReader; InputStreamReader java.io import java.io.LineNumberReader; LineNumberReader java.io public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } main {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } catch (Exception e) {
            System.exit(-1);
        } Exception e {
            System.exit(-1);
        } System.exit(-1) System.exit System -1 1 {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in)); lineNumReader new LineNumberReader(
                    new InputStreamReader(System.in)) String inputStr = null; inputStr null String w = null; w null long num = 0; num 0 while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            } (inputStr = lineNumReader.readLine()) != null (inputStr = lineNumReader.readLine()) inputStr lineNumReader.readLine() lineNumReader.readLine lineNumReader null {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            } if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                } lineNumReader.getLineNumber() == 1 lineNumReader.getLineNumber() lineNumReader.getLineNumber lineNumReader 1 {
                    w = inputStr.toLowerCase();
                } w = inputStr.toLowerCase() w inputStr.toLowerCase() inputStr.toLowerCase inputStr if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                } "END_OF_TEXT".equals(inputStr) "END_OF_TEXT".equals "END_OF_TEXT" inputStr {
                    // do nothing.
                    break;
                } break; if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                } lineNumReader.getLineNumber() > 1 lineNumReader.getLineNumber() lineNumReader.getLineNumber lineNumReader 1 {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                } inputStr = inputStr.toLowerCase() inputStr inputStr.toLowerCase() inputStr.toLowerCase inputStr String[] words = inputStr.split(" "); words inputStr.split(" ") inputStr.split inputStr " " for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    } String word words {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    } {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    } if (word.equalsIgnoreCase(w)) {
                            num++;
                        } word.equalsIgnoreCase(w) word.equalsIgnoreCase word w {
                            num++;
                        } num++ num System.out.println(num) System.out.println System.out System System.out num lineNumReader.close() lineNumReader.close lineNumReader String[] args args public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}