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++: #include <iostream>
using namespace std;
int main(void){
    int a=0;
    int e=1;
    int f=2;
    int z=0;
    cin>>a;
    char b[a];
    int d[a];
    for(int i=1;i<=a;i++){
        cin>>b[i];
    }
    for(int i=1;i<=a;i++){
        if(b[i]=='O'){
            d[i]=1;
        }else{
            if(b[i]=='X'){
                d[i]=2;
            }
        }
    }
    while(f<=a){
        if(d[e]+d[f]==3){
            z++;
            e=e+2;
            f=f+2;
        }else{
            e++;
            f++;
        }
    }
    cout<<z<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int dp[100001];

int main()
{
  int N;
  string S;

  cin >> N;
  cin.ignore();
  cin >> S;

  for (int i = 1; i <= N; i++) {
    dp[i] = max(dp[i], dp[i - 1]);
    if (S[i] != S[i - 1] && i <= N - 1) {
      dp[i + 1] = max(dp[i + 1], dp[i - 1] + 1);
    }
  }
  cout << dp[N] << endl;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,flg[100001]={0},cnt,i;
	char s[100001];
	scanf("%d %s",&n,s);
	cnt=0;
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1]&&flg[i]==0){
			cnt++;
			flg[i+1]=1;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

C++: #include<stdio.h> 
#include<iostream>
using namespace std;
int main() {
	int x=0, o=0, i, num, xo=0, g=0;
	char m[1000001];
	scanf("%d", &num);

	cin >> m;
	
	for (i = 0; i < num-1; i++) {
		if (m[i] == 'X' && m[i + 1] == 'O' || m[i] == 'O' && m[i + 1] == 'X') {
			xo++;
			i++;
		}
	}
	
	printf("%d\n", xo);
	return 0;
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    bool cnt = false;
    int ret = 0;
    for(int i = 0;i < N - 1;i++) {
        if(cnt == true) {
            cnt = false;
            continue;
        }
        if((S.at(i) == 'O' && S.at(i + 1) == 'X') || (S.at(i) == 'X' && S.at(i + 1) == 'O')) {
            ret++;
            cnt = true;
        }
    }
    cout << ret << endl;
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int N;
	int ans = 0;
	cin >> N;
	char S[100001];
	for (int i = 1; i <= N; i++){
		cin >> S[i];
	}
	for (int j = 1; j <= N; j++){
		if (S[j] == 'X'&&S[j + 1] == 'O'){
			S[j] = {};
			S[j + 1] = {};
			ans++;
		}
		else if (S[j] == 'O'&&S[j + 1] == 'X'){
			S[j] = {};
			S[j + 1] = {};
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n, ans;
string s;
int main()
{
    cin >> n >> s;
    for (int i = 0; i + 1 < n; i++)
    {
        if ((s[i] == 'O' && s[i + 1] == 'X') || (s[i] == 'X' && s[i + 1] == 'O'))
            ans++, i++;
    }
    cout << ans << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int idx = 0;
  int ans = 0;
  while(idx + 1 < N){
    if(S[idx] != S[idx + 1]){
      idx += 2;
      ans++;
    }else{
      idx++;
    }
  }
  cout << ans << "\n";
  return 0;
}

C++: #include <iostream>
using namespace std;

int main(void){
    int N;
    char S[100010];
    cin>>N;
    cin>>S;
    int count=0;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1]){
            count++;
            i++;
        }
    }
    cout<<count<<endl;
    return 0;

}

C++: #include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string com;
    int n, c;
    cin>>n;
    string s;
    cin>>s;
    int mb = 0;

    for(int i = 0; i < n-1; i++){
        if((s[i] == 'O' && s[i+1] == 'X') || (s[i] == 'X' && s[i+1] == 'O')){
            mb += 1;
            i++;
        }
    }
    cout<<mb<<endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int main(){
char s[100001];
int n,cnt=0;
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' || s[i]=='X'&& s[i+1]=='O'){
i++;
cnt++;
}
}
cout << cnt << endl;

return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	int n;
	string s;

	cin >> n >>  s;

	char prev = ' ';

	int ans = 0;

	for (char c : s) {
		if (prev == ' ') {
			prev = c;
		} else if (prev == 'O' && c == 'X') {
			prev = ' ';
			ans++;
		} else if (prev == 'X' && c == 'O') {
			prev = ' ';
			ans++; 
		}
	}
	cout << ans << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;

int main() {
    int n, ans = 0;
    string s; cin >> n >> s;

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

    cout << ans << endl;
}

C++: #include <iostream>
#include <string>
#include <limits>

using namespace std;
int main()
{
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    string S;
    cin >> S;
    int c = 0;
    for (int i = 1; i < S.size(); i++)
    {
        S[i - 1] != S[i] && (c++, i++);
    }
    cout << c << endl;
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    string S;
    cin >> N >> S;
    int i = 0, cnt = 0;
    while (i < N) {
        string T = S.substr(i, 2);
        if (T == "OX" || T == "XO") {
            ++cnt;
            i += 2;
        } else {
            ++i;
        }
    }
    cout << cnt << endl;
}