building tools=2000 world
building tools=2000 world
building tools=2000 world
building tools=5000 world
building tools=5000
building tools=2000
building tools=1000
building tools=5000
building tools=6000
shelter equipment=5000
construction equipment=5000
plants=1000
steel=8000
books=1000
water=5000 world
returns count as 5
package com.codegym.task.task19.task1907;
/*
Counting words
*/
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileReader reader = new FileReader(br.readLine());
br.close();
String file = "";
while(reader.ready()){
file = file+reader.read();
}
int count = 0;
int index = file.length();
while(index != -1){
index = file.indexOf("world");
if(index !=-1){
count++;
file = file.substring(index+5);
}
}
System.out.println(count);
reader.close();
}
}