import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final String EOT = "END_OF_TEXT"; EOT "END_OF_TEXT" String w w t; t int count = 0; count 0 w = sc.next() w sc.next() sc.next sc while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		} true {
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		} t = sc.next() t sc.next() sc.next sc if(t.equals(EOT)){
				break;
			} t.equals(EOT) t.equals t EOT {
				break;
			} break; if(t.equalsIgnoreCase(w)){
				count ++;
			} t.equalsIgnoreCase(w) t.equalsIgnoreCase t w {
				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[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
} public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
}