import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
} import java.io.File; File java.io import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	} main {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next(); W sc.next() sc.next sc int count = 0; count 0 while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		} true {
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		} String T = sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT")) break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; if(T.length() != W.length()) continue; T.length() != W.length() T.length() T.length T W.length() W.length W continue; boolean tf = true; tf true for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			} int i = 0; int i = 0; i 0 i < T.length() i T.length() T.length T i++ i++ i {
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			} {
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			} if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				} T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A') T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A') T.charAt(i) != W.charAt(i) T.charAt(i) T.charAt T i W.charAt(i) W.charAt W i (T.charAt(i) - 'a' + 'A') != W.charAt(i) (T.charAt(i) - 'a' + 'A') T.charAt(i) - 'a' T.charAt(i) T.charAt T i 'a' 'A' W.charAt(i) W.charAt W i T.charAt(i) != (W.charAt(i) - 'a' + 'A') T.charAt(i) T.charAt T i (W.charAt(i) - 'a' + 'A') W.charAt(i) - 'a' W.charAt(i) W.charAt W i 'a' 'A' {
					tf = false;
					break;
				} tf = false tf false break; if(tf){
				count++;
			} tf {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
} public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
} Main
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
}
