import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	}

} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	}

} Main public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	} main {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc a=a.toLowerCase() a a.toLowerCase() a.toLowerCase a String b = sc.next(); b sc.next() sc.next sc b=b.toLowerCase() b b.toLowerCase() b.toLowerCase b int c=0; c 0 while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			} a==a a a {
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			} if(a.equals(b)){
					c=c+1;
				} a.equals(b) a.equals a b {
					c=c+1;
				} c=c+1 c c+1 c 1 b=sc.next() b sc.next() sc.next sc if(b.equals("END_OF_TEXT")){
					break;
				} b.equals("END_OF_TEXT") b.equals b "END_OF_TEXT" {
					break;
				} break; b=b.toLowerCase() b b.toLowerCase() b.toLowerCase b System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	}

} public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	}

} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			a=a.toLowerCase();
			String b = sc.next();
			b=b.toLowerCase();
			int c=0;
			while(a==a){
				if(a.equals(b)){
					c=c+1;
				}
				b=sc.next();
				if(b.equals("END_OF_TEXT")){
					break;
				}
				b=b.toLowerCase();
			}
			System.out.println(c);
	}

}