import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} Main public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	} main {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	} BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		} catch( IOException e ) {
			System.err.println( e );
		} IOException e {
			System.err.println( e );
		} System.err.println( e ) System.err.println System.err System System.err e {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} String word = kb.readLine().toUpperCase(); word kb.readLine().toUpperCase() kb.readLine().toUpperCase kb.readLine() kb.readLine kb String str; str int cnt = 0; cnt 0 boolean endoftext = false; endoftext false while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        } null != ( str = kb.readLine() ) null ( str = kb.readLine() ) str kb.readLine() kb.readLine kb {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        } for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        } String wd str.split( " ", 0 ) str.split str " " 0 {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        } {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        } if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	} wd.equals( "END_OF_TEXT" ) wd.equals wd "END_OF_TEXT" {
		        		endoftext = true;
		        		break;
		        	} endoftext = true endoftext true break; wd = wd.toUpperCase() wd wd.toUpperCase() wd.toUpperCase wd if( wd.equals( word ) ) {
		        		cnt++;
		        	} wd.equals( word ) wd.equals wd word {
		        		cnt++;
		        	} cnt++ cnt if( endoftext ) { break; } endoftext { break; } break; System.out.println( cnt ) System.out.println System.out System System.out cnt String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine().toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}