:)
package com.codegym.task.task19.task1907;
/*
Counting words
*/
import java.io.*;
import java.nio.Buffer;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String file1 = br.readLine();
BufferedReader reader = new BufferedReader(new FileReader(file1));
int count = 0;
while(reader.ready()){
String words = String.valueOf(reader.read());
//this mean replace all punctuation to space and split by space, write all words into array.
String[] wordList = words.replaceAll("[^a-zA-Z]", " ").split(" ");
for(int i = 0; i < wordList.length; i++){
if(wordList.equals("world")){
count++;
}
}
}
br.close();
reader.close();
System.out.println(count);
}
}