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++: //john_doe 

#include <iostream>
#include <vector>
#include <string>
int main(){
    int N;
    std::cin>>N;

    std::string S;
    std::cin>>S;

    int cnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='O'&&S[i-1]=='X'){
            cnt++;
        }else if(S[i]=='O'&&S[i+1]=='X'){
            cnt++;
            S[i+1]='-';
        }
    }
    std::cout<<cnt<<'\n';
    return 0;
}

C++: #include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
using namespace std;


int main() {
	int n;
	string s;
	int ans=0;
	int pre = 0;//0=比較対象なし 1=〇 2=×

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

	cout<<ans<<endl;
	return 0;
}

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

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (S.substr(i, 2) == "OX" || S.substr(i, 2) == "XO")
      ++ans, ++i;
  }
  cout << ans << endl;
}

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

string S; int dp[100009], n;

int main() {
	cin >> n >> S;
	for (int i = 0; i <= 100000; i++) dp[i] = -(1 << 30);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			if (S[i] != S[i + 1]) dp[i + 2] = max(dp[i + 2], dp[i] + 1);
		}
		dp[i + 1] = max(dp[i + 1], dp[i]);
	}
	cout << dp[n] << endl;
	return 0;
}

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

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

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

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}

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

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

int main()
{
    const int    N(cin2var<int>());
    const string S(cin2var<string>());
    string       line(S);
    line.resize(N);
    int count = 0;
    while (true) {
        const auto iteOX(line.find("OX"));
        const auto iteXO(line.find("XO"));
        if (iteOX == string::npos && iteXO == string::npos) break;
        const auto iteMin(min(iteOX, iteXO));
        line = line.substr(iteMin + 2);
        ++count;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n + 1);
    for (int i = 0; i < n; ++i) {
        if (i && s[i] != s[i - 1]) {
            dp[i + 1] = max(dp[i], dp[i - 1] + 1);
        }
        else {
            dp[i + 1] = dp[i];
        }
    }
    cout << dp[n] << '\n';
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n_stamp;
  cin >> n_stamp;

  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < n_stamp - 1; i++) {
    // cout << s[i] << endl;
    if (s[i] != s[i + 1]) {
      cnt++;
      i++;
    }
  }

  cout << cnt << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,(int)s.size()) {
    if( i + 1 < (int)s.size() && s[i] != s[i+1] ) {
      ++cnt;
      ++i;
    }
  }
  cout << cnt << endl;
  compute();
  return 0;
}

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

int count_marubatu(string S, int N)
{
	int sum=0, count;
	rep(i, N-1)
	{
		count = 0;
		while(S[i+count]!=S[i+count+1] && i+count+1<N) count++;
		i += count;
		if(count%2==1) count++;
		sum += count/2;
	}
	return sum;
}

int main(void)
{
    int N;
    cin >> N;
	string S;
	cin >> S;
	int ans = count_marubatu(S, N);
	cout << ans << endl;
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<n-1;i++)
        if(s[i]!=s[i+1])
            ans++,i++;
    cout<<ans<<endl;
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int m=0;
    int ans=0;
    int cnt=0;
    while(m<n-1){
        if(s[m]!=s[m+1]){
            ans++;
            m+=2;
        }else{
            m++;
        }
    }
    m=n-1;
    while(m>0){
        if(s[m]!=s[m-1]){
            cnt++;
            m-=2;
        }else{
            m--;
        }
    }
    cout<<max(cnt,ans)<<endl;
}