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<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





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

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>
using namespace std;

#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); i++ )
#define REP( i, n )		FOR( i, 0, n )
#define ALL( x )		(x).begin(), (x).end()

int main( void ) {
	int n; cin >> n;

	vector<char> s(n);
	REP( i, n ) cin >> s[i];

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

	cout << count << endl;

}

C++: #include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
vector<vector<int>> graph;
map<char,ll> mp;
int main(){
int n;
cin>>n;
string s;
cin>>s;
int ans=0;
for(int i=0;i<n-1;i++){
    if(s.at(i)=='O'&&s.at(i+1)=='X'){ans++;i++;}
    else if(s.at(i)=='X'&&s.at(i+1)=='O'){ans++;i++;}
}
cout<<ans<<endl;
}

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

int main()
{
	//AOJ_Circle Cross Stamps
	int inputValue;
	int flag = 0;
	int countOXStamp = 0;
	char inputString[100000];
	
	cin >> inputValue;
	cin >> inputString;

	while (flag < inputValue)
	{
		if ((inputString[flag] == 'O') && (inputString[flag + 1] == 'X'))
		{
			flag += 2;
			countOXStamp++;
		}
		else if ((inputString[flag] == 'X') && (inputString[flag + 1] == 'O'))
		{
			flag += 2;
			countOXStamp++;
		}
		else
		{
			flag++;
		}
		
	}

	cout << countOXStamp << endl;

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(int argc,char* argv[]){
	int N,count=0;
	string S;
	cin >> N;
	cin >> S;
	for(int i=0;i<N-1;i++){
		if(S[i]=='X'&&S[i+1]=='O'){
			count++;
			i++;
		}else if(S[i]=='O'&&S[i+1]=='X'){
			count++;
			i++;
		} 
	}
	cout << count << endl;
	return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int main(){
    int n,i,ans;cin >> n;ans = 0;
    char s[n];
    for(i=0;i<n;i++)cin >> s[i];
    i = 1;
    if (n==1) cout << 0 << endl;
    else{
        while(i < n){
            if (s[i] != s[i-1]){
                ans += 1;i += 2;
            } else i += 1;
        }
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(S.substr(i,2) == "OX" or S.substr(i,2) == "XO"){
            cnt++;
            i++;
        }
    }
    cout << cnt << enld;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[1001001];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; string s; cin>>n>>s;
  s+='a';
  
  rep(i,n){
    if( (s[i]=='O'&&s[i+1]=='X') || (s[i]=='X'&&s[i+1]=='O') ) chmax(dp[i+2], dp[i]+1);
    chmax(dp[i+1], dp[i]);
  }
  
  ll ans=0;
  irep(i,n,n+3){
    chmax(ans, dp[i]);
  }
  cout<<ans<<endl;
  
}