JOI and IOI
InterviewTime limit1sMemory limit128 MB
Count how many length-3 windows of a string equal JOI and how many equal IOI, including overlaps.
- Level
Easy1 of 10
- Topics
- String, Brute force, Implementation
- Solved
- No attempts yet
Problem
You are given a string consisting only of uppercase letters. Write a program that counts how many times three consecutive characters form JOI and how many times they form IOI, and prints both counts.
Overlapping occurrences are counted separately. For example, JOIOIOI contains JOI once and IOI twice.
Input
The first line contains a string of length at most 10000, consisting only of uppercase letters.
Output
Print the number of occurrences of JOI on the first line, and the number of occurrences of IOI on the second line.