import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} Main public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	} main {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	} final String END_OF_TEXT = "END_OF_TEXT"; END_OF_TEXT "END_OF_TEXT" BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		} if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} br != null br null {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					br.close();
				} br.close() br.close br {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} String schStr = br.readLine().toLowerCase(); schStr br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br String str; str int cnt = 0; cnt 0 while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			} !(str = br.readLine()).equals(END_OF_TEXT) (str = br.readLine()).equals(END_OF_TEXT) (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br END_OF_TEXT {

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			} str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] sArr = str.split(" "); sArr str.split(" ") str.split str " " for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				} String wrd sArr {
					if(wrd.equals(schStr)){
						cnt++;
					}

				} {
					if(wrd.equals(schStr)){
						cnt++;
					}

				} if(wrd.equals(schStr)){
						cnt++;
					} wrd.equals(schStr) wrd.equals wrd schStr {
						cnt++;
					} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}