Go: package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	_, _ = fmt.Scan(&n)
	_, _ = fmt.Scan(&s)
	fmt.Println(calc(s))
}

func calc(s string) int {
	sum := 0
	ss := strings.Split(s,"")
	bf := 0
	for _, v := range ss{
		if bf == 0 {
			bf = cnv(v)
		} else if bf != cnv(v) {
			sum++
			bf = 0
		}
	}
	return sum
}

func cnv(s string) int {
	switch s {
	case "O":
		return 1
	case "X":
		return 2
	}
	return 0
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi dp(n+1,0);
    rep(i,n){
        dp[i+1] = max(dp[i+1],dp[i]);
        if(i < n-1)dp[i+2] = max(dp[i+2],dp[i] + (s[i] != s[i+1]));
    }
    cout << dp[n] << endl;
}

C++: #include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    REP(i,n-1){
        if(s[i]!=s[i+1]){
            ans++;
            i++;
        }
    }
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}

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

int main() {
    int count = 0;
    std::string s;
    int n;
    std::cin >> n;
    std::cin >> s;
    for (int i = 0; i < n-1; i++) {
        std::string p = {s[i], s[i+1]};
        if (p == "OX" || p == "XO") {
            count++;
            i++;
        }
    }
    std::cout << count << std::endl;

}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define DUMPL(ar) for(unsigned int i=0; i<ar.size(); i++) { cout << ar[i]; if(i<ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示"
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    for(int i=0; i<n; i++){
        // LOOPD(i);
        if(i == n-1){
            break;
        }
        if((s[i]=='O' && s[i+1]=='X') || (s[i]=='X' && s[i+1]=='O')){
            count++;
            i++;
        }
    }

    COUT(count);

    return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int flag1 = 0;
  int flag2 = 0;
  int flag = 0;
  int count = 0;

  for(int i = 0; i < n-1;) {
    if(s[i] != s[i+1]){
      count++;
      i+=2;
      flag = 1;
    }
    else {
      i++;
      flag = 0;
    }
  }


  cout << count << endl;
  /*
  for(int i = 0; i < n; i++) {
    if(s[i] == 'O' && flag1 == 0 && flag != 1) {
      flag1 = 1;
      flag = 1;
      cout << "1: " ;
    }
    else if(s[i] == 'X' && flag2 == 0 && flag != 1) {
      flag2 = 1;
      flag = 1;
      cout << "2: " ;
    }
    else if(s[i] == 'O' && flag2 == 1) {
      count++;
      flag2 = 0;
      flag1 = 0;
      flag = 0;
      cout << "3: " ;
    }
    else if(s[i] == 'X' && flag1 == 1) {
      count++;
      flag1 = 0;
      flag2 = 0;
      flag = 0;
      cout << "4: " ;
    }
    else {

      flag1 = 0;
      flag2 = 0;
      flag = 0;

      cout << "5: " ;

    }
  //  if(i % 2 == 0) cout << count << endl;


    cout <<"i:"<< i << " " << s[i] << " " << flag1 << " " << flag2 <<" " << count << endl;

  }

  if(flag1 == 1 && flag2 == 1) {
    count++;
  }
  */

}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;

int dp[ARRAY_MAX];

int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	int maxi = 0;

	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] != s[i + 1])
		{
			dp[i + 2] = max(dp[i + 2], max(maxi, dp[i] + 1));
			maxi = max(dp[i + 2], maxi);
		}
		else
		{
			dp[i + 2] = max(dp[i + 2], max(maxi, dp[i]));
			maxi = max(dp[i + 2], maxi);
		}
	}

	cout << dp[n] << endl;
}