You are given a string s consisting of n characters which are either 'X' or 'O'.

A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.

Return the minimum number of moves required so that all the characters of s are converted to 'O'.

&nbsp;
Example 1:

Input: s = "XXX"
Output: 1
Explanation: XXX -&gt; OOO
We select all the 3 characters and convert them in one move.


Example 2:

Input: s = "XXOX"
Output: 2
Explanation: XXOX -&gt; OOOX -&gt; OOOO
We select the first 3 characters in the first move, and convert them to 'O'.
Then we select the last 3 characters and convert them so that the final string contains all 'O's.

Example 3:

Input: s = "OOOO"
Output: 0
Explanation: There are no 'X's in s to convert.


&nbsp;
Constraints:


	3 &lt;= s.length &lt;= 1000
	s[i] is either 'X' or 'O'.


class Solution:
    def minimumMoves(self, s: str) -> int:
        i, m = 0, 0
        l = len(s)

        while i < l:
            if s[i] != 'X':
                i += 1
            elif 'X' not in s[i:i+1]:
                i += 2
            elif 'X' in s[i:i+2]:
                m += 1
                i += 3
        return m
class Solution {
    public int minimumMoves(String s) {
        int i=0;
        int step=0;
        while(i<s.length()){
            if(s.charAt(i)=='X'){
                i=i+3;
                step++;
            }
            else{
                i++;
            }
        }
        return step;
    }
}
class Solution {
public:
    int minimumMoves(string s) {
        int count=0;
        int i=0;
        
        for(int i=0;i<s.size();){
            if(s[i]=='O'){
             // continue;
              i++;}
            else{
              count++;
              i+=3;
            }
        }
        return count;
    }
};
var minimumMoves = function(s) {
    let move = 0;
    let i = 0;
    while(i<s.length){
        let char = s[i];
        // incrementing the index if we already have 'O'
        if(char== 'O'){
            i++;
        }
        // incrementing the move and index by 3 (Per move = 3 characters)
        if(char== 'X'){
            i=i+3;
            move++;
        }
    }
    return move;
};
Minimum Moves to Convert String