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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			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) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} String word = in.readLine(); word in.readLine() in.readLine in int count = 0; count 0 String line = ""; line "" while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			} (line = in.readLine()).equals("END_OF_TEXT") == false (line = in.readLine()).equals("END_OF_TEXT") (line = in.readLine()).equals (line = in.readLine()) line in.readLine() in.readLine in "END_OF_TEXT" false {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			} String words[] = line.split(" "); words line.split(" ") line.split line " " for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				} int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				} {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				} String str = words[i].toLowerCase(); str words[i].toLowerCase() words[i].toLowerCase words[i] words i if (word.equals(str) == true) {
						count++;
					} word.equals(str) == true word.equals(str) word.equals word str true {
						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) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String word = in.readLine();
			
			int count = 0;
			String line = "";
			while ((line = in.readLine()).equals("END_OF_TEXT") == false) {
				String words[] = line.split(" ");
				for (int i = 0; i < words.length; i++) {
					String str = words[i].toLowerCase();
					if (word.equals(str) == true) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}