import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
    public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
} Main public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    } main {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    } try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} final BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) final String key = input.readLine(); key input.readLine() input.readLine input int count = 0; count 0 String[] strs; strs while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			} true {
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			} strs = input.readLine().split(" ") strs input.readLine().split(" ") input.readLine().split input.readLine() input.readLine input " " if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    } strs[0].equals("END_OF_TEXT") strs[0].equals strs[0] strs 0 "END_OF_TEXT" {
			    	break;
			    } break; for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    } int i = 0; int i = 0; i 0 i < strs.length i strs.length strs strs.length i++ i++ i {
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    } {
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    } final String str = strs[i]; str strs[i] strs i if(str.equalsIgnoreCase(key)){
			            count++;
			        } str.equalsIgnoreCase(key) str.equalsIgnoreCase str key {
			            count++;
			        } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}