Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	s, _ := nextString()
	return strconv.Atoi(s)
}

func nextString() (string, bool) {
	succeeded := scanner.Scan()
	if succeeded {
		return scanner.Text(), succeeded
	}
	return "", succeeded
}

func printArr(arr []string) {
	fmt.Println(strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]"))
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	n, _ := nextInt()
	if n == 1 {
		fmt.Println(0)
		return
	}

	s, succeeded := nextString()
	if !succeeded {
		fmt.Errorf("Scan failed")
		return
	}
	nOX := 0
	i := 1
	for {
		if s[i] != s[i-1] {
			nOX++
			i++
		}
		i++
		if i >= n {
			break
		}
	}
	fmt.Println(nOX)
}

C++: /*
17D8101031C 杉山　祥吾 ID:keisei334 C++
*/

#include <iostream>

using namespace std;

#define N 100000

int main(void){
  int n,count=0;
  char s[N];

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }

  for(int i=0;i<n;i++){
    if(s[i]=='O' && s[i+1]=='X'){
      count++;
      i++;
    }else if(s[i+1]=='O' && s[i]=='X'){
      count++;
      i++;
    }
  }

  cout<<count<<"\n";
  
  return 0;
}

/*実行結果
5
OXXOX
2

14
OXOXOXOXXOXOXO
7

10
OOOOOOOOOO
0
*/

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

int main(){
//int W,H,x,y,r;
    int N;
    int M=0;
    char v;
    cin>>N;
    vector<char> X(N);

for(int i=0;i<N;i++){
    cin>>X.at(i);    
}

int c=0;
while(c<N-1){
  if(X.at(c)!=X.at(c+1)){
   M=M+1;
   c=c+2;
  
  }else{
    c=c+1;
    
}

}
cout<<M<<endl;

}