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++: /*
17D8101013F 森田　匡博
JOI0654.cpp 2019/10/31
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>
#include <string>

int main()
{
  int mb = 0; //マルバツ
  long long int N;
  std::cin >> N;

  std::string str;
  std::cin >> str;

  //std::cout << str[1];

  for(int i = 0; i < N; i++) {
    if(i != N - 1) {
      char s1 = str[i];
      char s2 = str[i+1];
      if((s1 == 'O' && s2 == 'X') || (s1 == 'X' && s2 == 'O')) {
	mb++;
	i += 1;
      }
    }
  }

  std::cout << mb << "\n";

  return 0;
}

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

using namespace std;

int larger(int x, int y){
	if(x > y){
		return x;
	}
	else{
		return y;
	}
}

int main(){
	int N;
	string S;
	cin >> N >> S;
	cout << N << "\n" << S << "\n";//test
	int memo[N+1];
	for(int i = 0; i < N + 1; i++){
		memo[i] = 0;
	}
	for(int i = 1; i < N; i++){
		if(S[i] != S[i-1]){
			memo[i+1] = larger(memo[i-1]+1, memo[i]);
		}
		else{
			memo[i+1] = memo[i];
		}
	}
	cout << memo[N] << "\n";
}

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for(int i = 0;i + 1 < N;i++){
        if(S[i] != S[i + 1]){
            ++res;
            ++i;
        }
    }
    cout << res << endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n, count;
    char ch[100000];
    count = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s", ch);
    }
    
    int i = 0;
    while(i < n-1){
        if(ch[i] == 'O'){
            if(ch[i+1] == 'X'){
                count++;
                i += 2;
            }
            else i++;
        }
        if(ch[i] == 'X'){
            if(ch[i+1] == 'O'){
                count++;
                i += 2;
            }
            else i++;
        }
        
    }
    printf("%d\n", count);
    return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
	ll n;
	cin >> n;
	char s[n + 1];
	cin >> s;
	ll cnt = 0;
	for(int i = 0; i < n - 1; i++){
		if(s[i] == 'O'){
			if(s[i + 1] == 'X') cnt++, i++;
		} else {
			if(s[i + 1] == 'O') cnt++, i++;
		}
	}
	cout << cnt << endl;
	return 0;
}

C++: #include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cstring>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <int MOD>
struct ModInt {
    long long val;
    constexpr ModInt(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr ModInt operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr ModInt operator+(const ModInt& r) const noexcept { return ModInt(*this) += r; }
    constexpr ModInt operator-(const ModInt& r) const noexcept { return ModInt(*this) -= r; }
    constexpr ModInt operator*(const ModInt& r) const noexcept { return ModInt(*this) *= r; }
    constexpr ModInt operator/(const ModInt& r) const noexcept { return ModInt(*this) /= r; }
    constexpr ModInt& operator+=(const ModInt& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr ModInt& operator/=(const ModInt& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator==(const ModInt& r) const noexcept { return this->val == r.val; }
    constexpr bool operator!=(const ModInt& r) const noexcept { return this->val != r.val; }
    friend constexpr ostream& operator<<(ostream& os, const ModInt<MOD>& x) noexcept { return os << x.val; }

    friend constexpr istream& operator>>(istream& is, ModInt<MOD>& x) noexcept { return is >> x.val; }
    friend constexpr ModInt<MOD> modpow(const ModInt<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = ModInt<MOD>;

long long modPow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

long long extGCD(long long a, long long b, long long& x, long long& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

template <typename T>
map<T, int> compress(vector<T> x) {
    map<T, int> res;
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    for (int i = 0; i < x.size(); i++) {
        res[x[i]] = i;
    }

    return res;
}

template <typename T>
int former(const vector<T>& v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template <typename T>
int latter(const vector<T>& v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

template <typename T>
using Vec = vector<T>;
template <typename T>
using VVec = vector<vector<T>>;
using LL = long long;

LL dp[100010];
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    memset(dp, -1, sizeof(dp));
    S.push_back('A');
    dp[0] = 0;
    REP(i, N) {
        if (dp[i] == -1) continue;
        chmax(dp[i + 1], dp[i]);
        if (S[i] == 'O' && S[i + 1] == 'X') chmax(dp[i + 2], dp[i] + 1);
        if (S[i] == 'X' && S[i + 1] == 'O') chmax(dp[i + 2], dp[i] + 1);
    }
    cout << dp[N] << endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 1; i++)
    {
        if(s[i] != s[i + 1])
        {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}