$stdin = DATA if $stdin.eof?

target = gets.chomp

words = []

ARGF.each_line do |line|
  break if line =~ /^END_OF_TEXT$/
  words += line.split
end

p words
puts words.select{|e| e =~ %r/#{target}/ }.size

__END__
computer
Nurtures computer scientists and highly-skilled computer engineers
who will create and exploit "knowledge" for the new era.
Provides an outstanding computer environment.
END_OF_TEXT