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 word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            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 word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            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 word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    } main {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    } try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            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 word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} final BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) final String word = input.readLine(); word input.readLine() input.readLine input int count = 0; count 0 boolean flag = true; flag true while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			} flag {
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			} for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    } final String str input.readLine().split(" ") input.readLine().split input.readLine() input.readLine input " " {
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    } {
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    } if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        } str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
			    		flag = false;
			    	} flag = false flag false if(str.equalsIgnoreCase(word)){
			            count++;
			        } str.equalsIgnoreCase(word) str.equalsIgnoreCase str word {
			            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 word = input.readLine();
			int count = 0;
			boolean flag = true;
			while(flag){
			    for(final String str : input.readLine().split(" ")){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(word)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}