Under construction

Still being built. Things may change

Wow and Queries

Interview

Time limit1sMemory limit1024 MB

Summary
Given Q strings made of W and O, count how many times the substring WOW appears in each one.
Level

Easy1 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

Hongik University has a mascot named Wow. People who see Wow cannot help but shout because it is so cute. While studying sounds, you learned how to measure how cute Wow is.

Let the sound people make be a string SS. You found that the number of occurrences of the substring WOW in SS is exactly how cute Wow is at that moment. Given QQ sounds, find the cuteness of each one.

Input

The first line contains the number of sounds QQ. (1≤Q≤1001 \leq Q \leq 100)

From the second line on, each of the next QQ lines gives one sound SS to analyze. (The length of SS is at least 11 and at most 1 0001\,000, and SS contains only W and O.)

Output

For each sound, print the cuteness of Wow analyzed from that sound, one per line, in input order.

Examples1

  1. Example 1

    Input
    4
    WOW
    WWO
    WOWOWWOW
    OWOOWOOW
    
    Expected output
    1
    0
    3
    0