#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std ;
typedef long long LL ;
const int N = 1e5 + 10 ;
int mark[2] ;
int num[N] ;
string s1 ;
int main(void) {
	int n ;
	cin >> n ;
	cin >> s1 ;
	for(int i = 0 ; i < n ; ++ i) {
		if(s1[i] == 'r') num[i] = 0 ;
		else if(s1[i] == 'b') num[i] = 1 ;
	}
	int last = num[0] ;
	for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	int res = 0 ;
    res = max(mark[0] , mark[1]) - 1 ;
	cout << res << endl ;
	return 0 ;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std ;
typedef long long LL ;
const int N = 1e5 + 10 ;
int mark[2] ;
int num[N] ;
string s1 ;
int main(void) {
	int n ;
	cin >> n ;
	cin >> s1 ;
	for(int i = 0 ; i < n ; ++ i) {
		if(s1[i] == 'r') num[i] = 0 ;
		else if(s1[i] == 'b') num[i] = 1 ;
	}
	int last = num[0] ;
	for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	int res = 0 ;
	if(mark[0] == mark[1]) res = (mark[0] + mark[1]) >> 1 ;
	else                   res = (mark[0] + mark[1]) >> 1 ;
	cout << res << endl ;
	return 0 ;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std ;
typedef long long LL ;
const int N = 1e5 + 10 ;
int mark[2] ;
int num[N] ;
string s1 ;
int main(void) {
	int n ;
	cin >> n ;
	cin >> s1 ;
	for(int i = 0 ; i < n ; ++ i) {
		if(s1[i] == 'r') num[i] = 0 ;
		else if(s1[i] == 'b') num[i] = 1 ;
	}
	int last = num[0] ;
	for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	int res = 0 ;
    res = max(mark[0] , mark[1]) - 1 ;
    last = ~num[0] ;
    mark[0] = 0 ; mark[1] = 0 ;
    for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	res = min(res , max(mark[0] , mark[1])) ;
	cout << res << endl ;
	return 0 ;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std ;
typedef long long LL ;
const int N = 1e5 + 10 ;
int mark[2] ;
int num[N] ;
string s1 ;
int main(void) {
	int n ;
	cin >> n ;
	cin >> s1 ;
	for(int i = 0 ; i < n ; ++ i) {
		if(s1[i] == 'r') num[i] = 0 ;
		else if(s1[i] == 'b') num[i] = 1 ;
	}
	int last = num[0] ;
	for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	//cout << mark[0] << " " << mark[1] << endl ;
	//system("pause") ;
	int res = 0 ;
	if(abs(mark[0] - mark[1]) <= 1) res = (mark[0] + mark[1]) >> 1 ;
	else {
		res = max(mark[0] , mark[1]) - min(mark[0] , mark[1]) ;
	}
	cout << res << endl ;
	return 0 ;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std ;
typedef long long LL ;
const int N = 1e5 + 10 ;
int mark[2] ;
int num[N] ;
string s1 ;
int main(void) {
	int n ;
	cin >> n ;
	cin >> s1 ;
	for(int i = 0 ; i < n ; ++ i) {
		if(s1[i] == 'r') num[i] = 0 ;
		else if(s1[i] == 'b') num[i] = 1 ;
	}
	int last = num[0] ;
	for(int i = 1 ; i < n ; ++ i) {
		if(num[i] == ~last) {
			last = ~last ;
			continue ;
		}
		else {
			mark[num[i]] ++ ;
			last = ~last ;
			continue ;
		}
	}
	int res = 0 ;
	if(abs(mark[0] - mark[1]) <= 1) res = min(mark[0] , mark[1]) ;
	else res = max(mark[0] , mark[1]) ;
	cout << res << endl ;
	return 0 ;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int arr[100000];
	long long m;
	cin >> m;
	string x;
	long long r = 0, b = 0,match;
	cin >> x;
	int len = x.length();

	for (int i = 0; i < len; i++)
	{
		if (i % 2 == 0)
			arr[i] = 0;
		else
			arr[i] = 1;
		if (x[i] == 'r'&&arr[i] == 0)
			r++;
		else if (x[i] == 'b'&&arr[i] == 1)
			b++;

	}
	match = max(r, b);
	cout << match << endl;
	cin >> match;

	return 0;
}


#include<iostream>
using namespace std;
int n,v[2][2];
char c;
int main() {
    cin>>n;
    for(int i = 0; i < n; ++i) cin>>c,++v[i%2][c=='r'];
    cout << min(max(v[0][0], v[1][1]), max(v[0][1], v[1][0])) << '\n';
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	bool arr[100000];
	long long m;
	cin >> m;
	string x;
	long long r = 0, b = 0,match;
	cin >> x;
	int len = x.length();
	char n = x[0];
	for (int i = 0; i < len; i++)
	{
		if (i % 2 == 0)
			arr[i] = 0;
		else
			arr[i] = 1;
		if (x[i] != n &&arr[i] == 0)
			r++;
		else  if (x[i] == n &&arr[i] == 1)
			b++;

	}
	match = max(r, b);
	cout << match << endl;
	cin >> match;

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	bool arr[100000];
	char z[100005];

	long long m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> z[i];
	}
	long long r = 0, b = 0,match;

	char n = z[0];
	for (int i = 0; i < m; i++)
	{
		if (i % 2 == 0)
			arr[i] = 0;
		else
			arr[i] = 1;
		if (z[i] != n &&arr[i] == 0)
			r++;
		else  if (z[i] == n &&arr[i] == 1)
			b++;

	}
	match = max(r, b);
	cout << match << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	char a[100005] = { 0 };
	long long r=0, b=0;
	char temp;
	int counter = 0,counter1=0;
	int x;
	cin >> x;
	for (int i = 0; i < x; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < x; i++)
	{

		if (a[i] == a[i + 1] && a[i] == 'r')
		{
			i += 2;
			counter++;
		}
		else if (a[i] == a[i + 1] && a[i] == 'b')
			{
			i += 2;
			counter1++;
			}
		}

	if (counter > counter1)
		cout << counter << endl;
	else
		cout << counter1 << endl;
	cin >> counter;

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int dembuoc(char *s, int n)
{
	int dem = 0;
	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			dem++;
			if(s[i] != s[i+1])
			{
				char c = s[i+1];
				s[i+1] = s[i];
				s[i] = c;
			}
			else
			{
				int luu = 0;
				for(int j = i+1; j < n; j+=2)
					if(s[i] != s[j])
					{
						char c = s[j];
						s[j] = s[i];
						s[i] = c;
						luu = 1;
						break;
					}
				if(!luu)
					s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}
	return dem;
}

int main()
{
	int n, dem1 = 0, dem2 = 0;

	cin>>n;

	char s[n], s2[n];

	cin>>s;
	for(int i = 0; i < n; i++)
		s2[i] = s[i];

	dem1 = dembuoc(s, n);
	s2[0] = (s2[0] == 'r')? 'b': 'r';

	dem2 = dembuoc(s2, n);
	cout<<((dem1 > dem2)? dem2+1: dem1)<<endl;

	return 0;
}


#include <iostream.h>
using namespace std;

const int maxn = 10000010;

int a[maxn];
char s[maxn];

int main() {

	int n;
	cin>>n>>s;

	int ans1, ans2, A, B;

	A = B = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0 && s[i] == 'r')
			A += 1;
		if (i % 2 == 1 && s[i] == 'b')
			B += 1;
	}
	ans1 = max(A, B);

	A = B = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0 && s[i] == 'b')
			A += 1;
		if (i % 2 == 1 && s[i] == 'r')
			B += 1;
	}
	ans2 = max(A, B);

	cout<<min(ans1,ans2)<<endl;

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int dembuoc(char *s, int n)
{
	int dem = 0;
	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			dem++;
			int luu = 0;
			for(int j = i+1; j < n; j+=2)
				if(s[i] != s[j])
				{
					char c = s[j];
					s[j] = s[i];
					s[i] = c;
					luu = 1;
					break;
				}
			if(!luu)
			{
				s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}
	return dem;
}

int main()
{
	int n, dem1 = 0, dem2 = 0;

	cin>>n;

	char s[n], s2[n];

	cin>>s;
	for(int i = 0; i < n; i++)
		s2[i] = s[i];

	dem1 = dembuoc(s, n);
	s2[0] = (s2[0] == 'r')? 'b': 'r';

	dem2 = dembuoc(s2, n);
	cout<<((dem1 > dem2)? dem2+1: dem1)<<endl;

	return 0;
}


#include <iostream>

using namespace std;

int n, v[2][2];
char c;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> c, ++v[i%2][c=='r'];
    cout << min(max(v[0][0], v[1][1]), max(v[0][1], v[1][0])) << '\n';
}


#include <iostream>
#include <string>
using namespace std;

int dembuoc(char *s, int n)
{
	int dem = 0;
	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			dem++;
			int luu = 0;
			for(int j = i+1; j < n; j+=2)
				if(s[i] != s[j])
				{
					char c = s[j];
					s[j] = s[i];
					s[i] = c;
					luu = 1;
					break;
				}
			if(!luu)
			{
				s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}
	return dem;
}

int main()
{
	int n, dem1 = 0, dem2 = 0;

	cin>>n;

	char s[n], s2[n];

	cin>>s;
	//for(int i = 0; i < n; i++)
	//	s2[i] = s[i];

	dem1 = dembuoc(s, n);
	//s2[0] = (s2[0] == 'r')? 'b': 'r';

	//dem2 = dembuoc(s2, n);
	cout<<dem1<<endl;//((dem1 > dem2)? dem2+1: dem1)<<endl;

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int dembuoc(char *s, int n)
{
	int dem = 0;
	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			dem++;
			int luu = 0;
			if(s[i] != s[i+1])
			{
				char c = s[i+1];
				s[i+1] = s[i];
				s[i] = c;
				dem++;
				return dem;
			}
			for(int j = i+2; j < n; j+=2)
				if(s[i] != s[j] && s[j-1] != s[i])
				{
					char c = s[j];
					s[j] = s[i];
					s[i] = c;
					luu = 1;
					break;
				}
			if(!luu)
			{
				s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}
	return dem;
}

int main()
{
	int n, dem1 = 0, dem2 = 0;

	cin>>n;

	char s[n], s2[n];

	cin>>s;
	for(int i = 0; i < n; i++)
		s2[i] = s[i];

	dem1 = dembuoc(s, n);
	s2[0] = (s2[0] == 'r')? 'b': 'r';

	dem2 = dembuoc(s2, n);
	cout<<((dem1 > dem2)? dem2+1: dem1)<<endl;

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, dem = 0;

	cin>>n;

	string s;

	cin>>s;

	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			dem++;
			int luu = 0;
			for(int j = i+1; j < n; j+=2)
				if(s[i] != s[j])
				{
					char c = s[j];
					s[j] = s[i];
					s[i] = c;
					luu = 1;
					break;
				}
			if(!luu)
			{
				s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}

	cout<<dem<<endl;
	return 0;
}


#include <iostream>
using namespace std;

const int maxn = 10000010;

int a[maxn];
char s[maxn];

int main() {

	int n;
	cin>>n>>s;

	int ans1, ans2, A, B;

	A = B = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0 && s[i] == 'r')
			A += 1;
		if (i % 2 == 1 && s[i] == 'b')
			B += 1;
	}
	ans1 = max(A, B);

	A = B = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0 && s[i] == 'b')
			A += 1;
		if (i % 2 == 1 && s[i] == 'r')
			B += 1;
	}
	ans2 = max(A, B);

	cout<<min(ans1,ans2)<<endl;

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, dem = 0;

	cin>>n;

	string s;

	cin>>s;

	for(int i = 1; i < n; i++)
		if(s[i] == s[i-1])
		{
			if(s[i] != s[i+1] && i+1 < n)
			{
				dem++;
				char c = s[i+1];
				s[i+1] = s[i];
				s[i] = c;
			}
			else
			{
				dem++;
				i-1;
				s[i] = (s[i] == 'b')? 'r': 'b';
			}
		}
	cout<<dem<<endl;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    char rb[n];
    bool tf[n];
    bool tf2[n];
    tf[0]=true;
    tf2[0]=false;
    int b1=0,b2=0,r1=0,r2=0;
    for(int i=0;i<n;i++){
        cin>>rb[i];
        if(i>0){
            if(rb[i]==rb[i-1]){
                if(tf[i-1]){
                    if(rb[i]=='b')b1++;
                    else r1++;
                    tf[i]=false;
                }
                else tf[i]=true;
                if(tf2[i-1]){
                    if(rb[i]=='b')b2++;
                    else r2++;
                    tf2[i]=false;
                }
                else tf2[i]=true;
            }
            else{
                if(tf[i-1])tf[i]=true;
                else{
                    if(rb[i]=='b')b1++;
                    else r1++;
                    tf[i]=false;
                }
                if(tf2[i-1])tf2[i]=true;
                else{
                    if(rb[i]=='b')b2++;
                    else r2++;
                    tf2[i]=false;
                }
            }
        }
        else{
            if(rb[0]=='r')r2++;
            else b2++;
        }
    }
    cout<<min(max(b1,r1),max(b2,r2));
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n],arr2[n];
    char rb;
    for(int i=0;i<n;i++){
        cin>>rb;
        if(rb=='b'){
            arr[i]=0;
            arr2[i]=0;
        }
        else{
            arr[i]=1;
            arr2[i]=1;
        }
    }
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    int counter1=0;
    int counter2=0;
    if(arr[0]==1){
        if(arr[0]!=arr[1]) swap(arr[0],arr[1]);
        else arr[0]=0;
        counter1++;
    }
    for(int i=1;i<n;i++){
        if(arr[i]==arr[i-1]){
            if(i==n-1){
                counter1++;
                break;
            }
            if(arr[i]!=arr[i+1])swap(arr[i],arr[i+1]);
            else{
                if(arr[i]==1)arr[i]=0;
                else arr[i]=1;
            }
            counter1++;
        }
    }
    if(arr2[0]==0){
        if(arr2[0]!=arr2[1])swap(arr2[0],arr2[1]);
        else arr2[0]=1;
        counter2++;
    }
    for(int i=1;i<n;i++){
        if(arr2[i]==arr2[i-1]){
            if(i==n-1){
                counter2++;
                break;
            }
            if(arr2[i]!=arr2[i+1])swap(arr2[i],arr2[i+1]);
            else{
                if(arr2[i]==1)arr2[i]=0;
                else arr2[i]=1;
            }
            counter2++;
        }
    }

    cout<<min(counter1,counter2)<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    bool downorup=false;
    for(int i=1;i<n;i++){
        if(arr[i]>arr[i-1]&&arr[i]!=15)downorup=true;
        else if(arr[i]==15)downorup=false;
        else if(arr[i]<arr[i-1]&&arr[i]!=0)downorup=false;
        else if(arr[i]<arr[i-1]&&arr[i]==0)downorup=true;
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    if(n==1&&arr[0]==15)cout<<"DOWN"<<endl;
    else if(n==1&&arr[0]==0)cout<<"UP"<<endl;
    else if(n<=1)cout<<-1<<endl;
    else if(downorup)cout<<"UP"<<endl;
    else cout<<"DOWN"<<endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    char rb[n];
    bool tf[n];
    bool tf2[n];
    tf[0]=true;
    tf2[0]=false;
    int k1=1;
    int k2=1;
    int b1=0,b2=0,r1=0,r2=0;
    for(int i=0;i<n;i++){
        cin>>rb[i];
        if(i>0){
            if(rb[i]==rb[i-1]){
                if(tf[i-1]){
                    if(rb[i]=='b')b1++;
                    else r1++;
                    tf[i]=false;
                    k1++;
                }
                else tf[i]=true;
                if(tf2[i-1]){
                    if(rb[i]=='b')b2++;
                    else r2++;
                    tf2[i]=false;
                    k2++;
                }
                else tf2[i]=true;
            }
            else{
                if(tf[i-1])tf[i]=true;
                else{
                    if(rb[i]=='b')b1++;
                    else r1++;
                    tf[i]=false;
                    k1++;
                }
                if(tf2[i-1])tf2[i]=true;
                else{
                    if(rb[i]=='b')b2++;
                    else r2++;
                    tf2[i]=false;
                    k2++;
                }
            }
        }
    }
    cout<<min(max(b1,r1),max(b2,r2));
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<map>
#include<string>
#include<algorithm>
#define N 100010

using namespace std;

char ch[N];

int main()
{
    int n;
    char str[3] = {'r','b','\0'};
    while(~scanf("%d%s", &n, ch))
    {
        int sumb = 0, sumr = 0, sum1 = 0, sum2 = 0, sum = 0;
        for(int i = 0;i < n;i ++)
        {
            if(ch[i] != str[i % 2] && ch[i] == 'b') sumb ++;
            if(ch[i] != str[i % 2] && ch[i] == 'r') sumr ++;
            if(ch[i] != str[(i + 1) % 2] && ch[i] == 'r') sum1 ++;
            if(ch[i] != str[(i + 1) % 2] && ch[i] == 'b') sum2 ++;
        }
        sum = min(max(sumr,sumb),max(sum1,sum2));
        printf("%d\n",sum);
     }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<map>
#include<string>
#include<algorithm>
#define N 100010

using namespace std;

char ch[N];

int main()
{
    int n;
    char str[3] = {'r','b','\0'};
    while(~scanf("%d%s", &n, ch))
    {
        int a = 0, b = 0, sum1 = 0, sum2 = 0;
        for(int i = 0;i < n;i ++)
        {
            if(ch[i] != str[i % 2]) a ++;
            else
            {
                if(a == 1) sum1 += 1;
                else sum1 += a / 2 + a % 2;
                a = 0;
            }
            if(ch[i] != str[(i + 1) % 2]) b ++;
            else
            {
                if(b == 1) sum2 += 1;
                else sum2 += b / 2 + b % 2;
                b = 0;
            }
        }
        sum1 > sum2 ? printf("%d\n",sum2) : printf("%d\n",sum1);
     }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<map>
#include<string>
#include<algorithm>
#define N 100010

using namespace std;

char ch[N];

int main()
{
    int n;
    char str[3] = {'r','b','\0'};
    while(~scanf("%d%s", &n, ch))
    {
        int a = 0, b = 0, sum1 = 0, sum2 = 0;
        for(int i = 0;i < n;i ++)
        {
            if(ch[i] != str[i % 2]) a ++;
            else
            {
                //printf("%d\n",a);
                sum1 += ((a / 2) + (a % 2));
                a = 0;
            }
            if(ch[i] != str[(i + 1) % 2]) b ++;
            else
            {
                //printf("%d\n",b);
                sum2 += ((b / 2) + (b % 2));
                b = 0;
            }
        }
        sum1 += (a / 2 + a % 2);sum2 += (b / 2 + b % 2);
        //printf("%d\n%d\n",sum1,sum2);
        sum1 > sum2 ? printf("%d\n",sum2) : printf("%d\n",sum1);
     }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<map>
#include<string>
#include<algorithm>
#define N 100010

using namespace std;

char ch[N];

int main()
{
    int n;
    char str[3] = {'r','b','\0'};
    while(~scanf("%d%s", &n, ch))
    {
        int a = 0, b = 0, sum1 = 0, sum2 = 0;
        for(int i = 0;i < n;i ++)
        {
            if(ch[i] != str[i % 2]) a ++;
            else
            {
                sum1 += (a / 2 + a % 2);
                a = 0;
            }
            if(ch[i] != str[(i + 1) % 2]) b ++;
            else
            {
                sum2 += (b / 2 + b % 2);
                b = 0;
            }
        }
        sum1 > sum2 ? printf("%d\n",sum2) : printf("%d\n",sum1);
     }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,count_rr=0,count_br=0,count_ra=0,count_ba=0,l1,l3,l2,out;
cin>>n;
string a;
cin>>a;
string r;
string b;
for(i=0;i<n;i++){
	if(!(i&1))
	r[i]='r';
	else
	r[i]='b';
}
for(i=0;i<n;i++){
	if(!(i&1))
	b[i]='b';
	else
	b[i]='r';
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=r[i])
		count_rr++;
	}
	if(!(i&1)){
		if(a[i]!=r[i])
		count_br++;
	}
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=b[i])
		count_ba++;
	}
	else{
		if(a[i]!=b[i])
		count_ra++;
	}
}
l1=min(count_rr,count_ra);
l2=min(count_br,count_ba);
out=max(l1,l2);
cout<<out;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,count_rr=0,count_br=0,count_ra=0,count_ba=0,l1,l3,l2,out;
cin>>n;
string a;
cin>>a;
char r[100001],b[100001];
for(i=0;i<n;i++){
	if(i%2==0)
	r[i]='r';
	else
	r[i]='b';
}
for(i=0;i<n;i++){
	if(i%2==0)
	b[i]='b';
	else
	b[i]='r';
}
for(i=0;i<n;i++){
	if(i%2==0){
		if(a[i]!=r[i])
		count_rr++;
	}
	if(i%2!=0){
		if(a[i]!=r[i])
		count_br++;
	}
}
for(i=0;i<n;i++){
	if(i%2==0){
		if(a[i]!=b[i])
		count_ba++;
	}
	if(i%2!=0){
		if(a[i]!=b[i])
		count_ra++;
	}
}
l1=min(count_rr,count_ra);
l2=min(count_br,count_ba);
out=max(l1,l2);
cout<<out;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define HELP ios_base::sync_with_stdio(false);
int main(){
	int n,i,count_rr=0,count_br=0,count_ra=0,count_ba=0,l1,l3,l2,out;
	HELP
cin>>n;
string a;
cin>>a;
string r;
string b;
for(i=0;i<n;i++){
	if(!(i&1))
	r[i]='r';
	else
	r[i]='b';
}
for(i=0;i<n;i++){
	if(!(i&1))
	b[i]='b';
	else
	b[i]='r';
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=r[i])
		count_rr++;
	}
	if(!(i&1)){
		if(a[i]!=r[i])
		count_br++;
	}
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=b[i])
		count_ba++;
	}
	else{
		if(a[i]!=b[i])
		count_ra++;
	}
}
l1=min(count_rr,count_ra);
l2=min(count_br,count_ba);
out=max(l1,l2);
cout<<out;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,l,disturbance=0;
cin>>n;
string a;
cin>>a;
l=a.length();
if(a[0]=='r'){
	for(i=1;i<l;i++){
		if(i%2==1){
			if(a[i]!='b')
			disturbance++;
		}
		if(i%2==0){
			if(a[i]!='r'){
				if(a[i-1]!='b')
				disturbance++;
			}
		}
	}
}

if(a[0]=='b'){
	for(i=1;i<l;i++){
		if(i%2==1){
			if(a[i]!='r')
			disturbance++;
		}
		if(i%2==0){
			if(a[i]!='b'){
				if(a[i-1]!='r')
				disturbance++;
			}
		}
	}
}
cout<<disturbance;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,count_rr=0,count_br=0,count_ra=0,count_ba=0,l1,l3,l2,out;
cin>>n;
string a;
cin>>a;
string r;
string b;
for(i=0;i<n;i++){
	if(i%2==0)
	r[i]='r';
	else
	r[i]='b';
}
for(i=0;i<n;i++){
	if(i%2==0)
	b[i]='b';
	else
	b[i]='r';
}
for(i=0;i<n;i++){
	if(i%2==0){
		if(a[i]!=r[i])
		count_rr++;
	}
	if(i%2!=0){
		if(a[i]!=r[i])
		count_br++;
	}
}
for(i=0;i<n;i++){
	if(i%2==0){
		if(a[i]!=b[i])
		count_ba++;
	}
	if(i%2!=0){
		if(a[i]!=b[i])
		count_ra++;
	}
}
l1=min(count_rr,count_ra);
l2=min(count_br,count_ba);
out=max(l1,l2);
cout<<out;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define HELP ios_base::sync_with_stdio(false);
int main(){
	int n,i,count_rr=0,count_br=0,count_ra=0,count_ba=0,l1,l3,l2,out;
	HELP
cin>>n;
string a;
cin>>a;
char b[100001],r[100001];
for(i=0;i<n;i++){
	if(!(i&1))
	r[i]='r';
	else
	r[i]='b';
}
for(i=0;i<n;i++){
	if(!(i&1))
	b[i]='b';
	else
	b[i]='r';
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=r[i])
		count_rr++;
	}
	if(!(i&1)){
		if(a[i]!=r[i])
		count_br++;
	}
}
for(i=0;i<n;i++){
	if(!(i&1)){
		if(a[i]!=b[i])
		count_ba++;
	}
	else{
		if(a[i]!=b[i])
		count_ra++;
	}
}
l1=min(count_rr,count_ra);
l2=min(count_br,count_ba);
out=max(l1,l2);
cout<<out;
return 0;
}


// <b.cpp> - 09/23/16 21:03:49
// Created by Lai Ruihang: MasterJH5574.
// Everytime, try the best.
// And always like like.

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <queue>
#include <string>
#include <map>
typedef long long ll;
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n;
char s[MAXN];
int color[MAXN], g[MAXN][2];
int ans1, ans2, ls1, ls2;

int gi() {
    char c;
    int sum = 0, f = 1;
    c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum * f;
}

int main() {
    //file("b");
    n = gi();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        color[i] = s[i] == 'r' ? 1 : 0;
        g[i][0] = i & 1;
        g[i][1] = !(i & 1);
        if (color[i] != g[i][0]) {
            if (color[i]) {
                if (ls1 <= 0)
                    ans1++;
                ls1--;
            } else {
                if (ls1 >= 0)
                    ans1++;
                ls1++;
            }
        } else {
            if (color[i]) {
                if (ls2 <= 0)
                    ans2++;
                ls2--;
            } else {
                if (ls1 >= 0)
                    ans2++;
                ls2++;
            }
        }
    }
    printf("%d", min(ans1, ans2));
    return 0;
}


// <b.cpp> - 09/23/16 21:03:49
// Created by Lai Ruihang: MasterJH5574.
// Everytime, try the best.
// And always like like.

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <queue>
#include <string>
#include <map>
typedef long long ll;
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n;
char s[MAXN];
bool color[MAXN];
int ans1, ans2, ls1, ls2;

int main() {
    //file("b");
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        color[i] = s[i] == 'r' ? 1 : 0;
        if (color[i] != (i & 1)) {
            if (color[i]) {
                if (ls1 <= 0)
                    ans1++;
                ls1--;
            } else {
                if (ls1 >= 0)
                    ans1++;
                ls1++;
            }
        } else {
            if (color[i]) {
                if (ls2 <= 0)
                    ans2++;
                ls2--;
            } else {
                if (ls2 >= 0)
                    ans2++;
                ls2++;
            }
        }
    }
    printf("%d", min(ans1, ans2));
    return 0;
}


// <b.cpp> - 09/23/16 21:03:49
// Created by Lai Ruihang: MasterJH5574.
// Everytime, try the best.
// And always like like.

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <queue>
#include <string>
#include <map>
typedef long long ll;
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n, INF = 1;
char s[MAXN];
int color[MAXN], g[MAXN][2];
int ans1, ans2, lc1 = -1, lc2 = -1;
int f[MAXN][2];

int gi() {
    char c;
    int sum = 0, f = 1;
    c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum * f;
}

int main() {
    //file("b");
    for (int i = 1; i <= 30; i++)
        INF <<= 1;
    n = gi();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        color[i] = s[i] == 'r' ? 1 : 0;
        g[i][0] = i & 1;
        g[i][1] = !(i & 1);
        if (color[i] != g[i][0]) {
            if (lc1 != i - 1) {
                ans1++;
                lc1 = i;
            }
        } else {
            if (lc2 != i - 1) {
                ans2++;
                lc2 = i;
            }
        }
    }
    printf("%d", min(ans1, ans2));
    /*
    f[1][color[1] ^ 1] = 1;
    for (int i = 2; i <= n; i++) {
        f[i][0] = f[i][1] = INF;
        if (color[i] != color[i - 1]) {
            f[i][color[i]] = min(f[i - 2][color[i]], f[i - 1][color[i] ^ 1]);
            f[i][color[i] ^ 1] = min(f[i - 2][color[i] ^ 1] + 1, f[i - 1][color[i]] + 1);
        } else {
            f[i][color[i]] = f[i - 1][color[i] ^ 1];
            f[i][color[i] ^ 1] = f[i - 1][color[i]] + 1;
        }
    }
    printf("%d", min(f[n][0], f[n][1]));
    */
    return 0;
}


// <b.cpp> - 09/23/16 21:03:49
// Created by Lai Ruihang: MasterJH5574.
// Everytime, try the best.
// And always like like.

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <queue>
#include <string>
#include <map>
typedef long long ll;
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n, INF = 1;
char s[MAXN];
int color[MAXN];
int f[MAXN][2];

int gi() {
    char c;
    int sum = 0, f = 1;
    c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum * f;
}

int main() {
    //file("b");
    for (int i = 1; i <= 30; i++)
        INF <<= 1;
    n = gi();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++)
        color[i] = s[i] == 'r' ? 1 : 0;
    f[1][color[1] ^ 1] = 1;
    for (int i = 2; i <= n; i++) {
        f[i][0] = f[i][1] = INF;
        if (color[i] != color[i - 1]) {
            f[i][color[i]] = min(f[i - 2][color[i]], f[i - 1][color[i] ^ 1]);
            f[i][color[i] ^ 1] = min(f[i - 2][color[i] ^ 1] + 1, f[i - 1][color[i]] + 1);
        } else {
            f[i][color[i]] = f[i - 1][color[i] ^ 1];
            f[i][color[i] ^ 1] = f[i - 1][color[i]] + 1;
        }
    }
    printf("%d", min(f[n][0], f[n][1]));
    return 0;
}


// <b.cpp> - 09/23/16 21:03:49
// Created by Lai Ruihang: MasterJH5574.
// Everytime, try the best.
// And always like like.

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <queue>
#include <string>
#include <map>
typedef long long ll;
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n, INF = 1;
char s[MAXN];
int color[MAXN];
int f[MAXN][2];

int gi() {
    char c;
    int sum = 0, f = 1;
    c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum * f;
}

int main() {
    //file("b");
    for (int i = 1; i <= 30; i++)
        INF <<= 1;
    n = gi();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++)
        color[i] = s[i] == 'r' ? 1 : 0;
    f[1][color[1] ^ 1] = 1;
    for (int i = 2; i <= n; i++) {
        f[i][0] = f[i][1] = INF;
        if (color[i] != color[i - 1]) {
            f[i][color[i]] = min(f[i][color[i]], f[i - 2][color[i]]);
            f[i][color[i] ^ 1] = min(f[i][color[i] ^ 1], min(f[i - 2][color[i] ^ 1] + 1, f[i - 1][color[i]] + 1));
        } else {
            f[i][color[i]] = min(f[i][color[i]], f[i - 1][color[i] ^ 1]);
            f[i][color[i] ^ 1] = min(f[i][color[i] ^ 1], f[i - 1][color[i]] + 1);
        }
    }
    printf("%d", min(f[n][0], f[n][1]));
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//char ch[100005];
int main()
{
    int n,co=0;
    string ch;
    char c;
    cin>>n;
    cin.get(c);
    getline(cin,ch);
    if(n%2==1)
        n--;

    for(int i=0;i<n;i++)
    {
        if((ch[i]=='b')&&(ch[i+1]=='r'))
        {
          i++;
        }

        else if((ch[i]=='r')&&(ch[i+1]=='b'))
        {
        i++;
        }
            else
        {
           co++;
           i++;

        }

    }
    cout<<co;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[2],b[2];
int main()
{

char c;

cin>>n;
cin.get(c);
string ch;
cin>>ch;
for(int i=1;i<n;i++)
{
   if(ch[i]=='b')
        a[i&1]++;
   else
       b[i&1]++;
}
cout<<min(max(a[0],b[1]),max(a[1],b[0]))<<'\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[2],b[2];
int main()
{

char c;

cin>>n;
cin.get(c);
string ch;
cin>>ch;
for(int i=0;i<n;i++)
{
   if(ch[i]=='b')
        a[i&1]++;
   else
       b[i&1]++;
}
cout<<min(max(a[0],b[1]),max(a[1],b[0]))<<'\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[2],b[2];
int main()
{

char c;

cin>>n;
cin.get(c);
string ch;
cin>>ch;
for(int i=1;i<n;i++)
{
   if(ch[i]=='r')
        a[i&1]++;
   else
       b[i&1]++;
}
cout<<min(max(a[0],b[1]),max(a[1],b[0]))<<'\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
//char ch[100005];
int main()
{
    int n,co=0;
    string ch;
    char c;
    cin>>n;
    cin.get(c);
    getline(cin,ch);
    if(n%2==1)
        n--;
        int f=0;

    for(int i=0;i<n-1;i++)
    {
        if(i>=1)
        {
            if(ch[i]==ch[i-1])
                  co++;
        }

        if(ch[i]!=ch[i+1])
                i++;

            else
        {
            if(ch[i]=='r')
                ch[i+1]='b';
            else
                ch[i+1]='r';
           co++;
           i++;

        }

    }
    cout<<co;

    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
//    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;

    int suma=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i]&&crs[j]!=crs[i])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {

        if(crs[i]!=crsw[i]){
        suma++;
        crs[i]=crsw[i];}
    }

    int mini=suma;

    resetCrs();

    suma=0;
    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;

    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {
        if(crs[i]!=crsw[i]){
        suma++;
        crs[i]=crsw[i];}
    }
    mini=min(suma,mini);
    cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
//    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;
    int r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }
    int suma=max(r,b);
    int mini=suma;

//
resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;
    int r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }

//

     mini=min(suma,mini)
    cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
    //freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();
    for(int i=0; i<n; ++i)
    {
        crsw[i]=i%2;
    }
    int mini=fixc();

    resetCrs();
    for(int i=0; i<n; ++i)
    {
        crsw[i]=(i+1)%2;
    }

    mini=min(fixc(),mini);

cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
//    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;
    int r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }
    int suma=max(r,b);
    int mini=suma;

//
resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;
    r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }

//

     mini=min(suma,mini);
    cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
//    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;

    int suma=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i]&&crs[j]==crsw[i]&&crs[i]==crsw[j])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {

        if(crs[i]!=crsw[i])
        {
            suma++;
            crs[i]=crsw[i];
        }
    }

    int mini=suma;

    resetCrs();

    suma=0;
    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;

    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i]&&crs[j]==crsw[i]&&crs[i]==crsw[j])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {
        if(crs[i]!=crsw[i])
        {
            suma++;
            crs[i]=crsw[i];
        }
    }
    mini=min(suma,mini);
    cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;

    int suma=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i]&&crs[j]==crsw[i]&&crs[i]==crsw[j])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {

        if(crs[i]!=crsw[i])
        {
            suma++;
            crs[i]=crsw[i];
        }
    }

    int mini=suma;

    resetCrs();

    suma=0;
    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;

    for(int i=0; i<n; ++i)
    {
        for(int j=i+1; j<n; ++j)
        {
            if(crs[j]!=crsw[j]&&crs[i]!=crsw[i]&&crs[j]==crsw[i]&&crs[i]==crsw[j])
            {
                swap(crs[j],crs[i]);
                suma++;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {
        if(crs[i]!=crsw[i])
        {
            suma++;
            crs[i]=crsw[i];
        }
    }
    mini=min(suma,mini);
    cout<<mini;
    return 0;
}


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

bool crs[100001];//cockroaches

bool crsw[100001];//cockroaches wanted
string c;
int n;

void resetCrs()
{
    for(int i=0; i<n; ++i)
    {
        crs[i]=c[i]=='r';/// red is one
    }

}

int fixc()
{
    int suma=0;

    for(int i=0; i<n-1; ++i)
    {
        if(crs[i]!=crsw[i]&&crs[i+1]!=crsw[i+1])
        {
            swap(crs[i],crs[i+1]);
            suma++;
        }

        if(crs[i]!=crsw[i])
        {
            crs[i]=crsw[i];
            suma++;
        }
    }
    if(crs[n-1]!=crsw[n-1])
    {
        crs[n-1]=crsw[n-1];
        suma++;
    }
    return suma;
}

int main()
{
//    freopen("input.txt","r",stdin);

    cin >> n;

    cin>>c;

    resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=i%2;
    int r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }
    int suma=max(r,b);
    int mini=suma;

//
resetCrs();

    for(int i=0; i<n; ++i)
        crsw[i]=(1+i)%2;
    r=0,b=0;
    for(int i=0;i<n;++i){
        if(crs[i]!=crsw[i]){
            if(crs[i]==0)
                ++b;
            else
                ++r;
        }
    }

//

    suma=max(r,b);

     mini=min(suma,mini);
    cout<<mini;
    return 0;
}


#include<stdio.h>
#include<string.h>
int R,B,ans;
char shit[101000];
bool mp[101000];
int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",shit+1);
	for(int i=1;i<=n;i++)
	{
		if(shit[i]=='b')mp[i]=false;
		else mp[i]=true;
		if(i==1)continue;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	int sb=ans;
	R=0,B=0;
	if(mp[1])B++;
	else R++;
	mp[1]=!mp[1];
	ans=1;
	for(int i=2;i<=n;i++)
	{
		if(shit[i]=='b')mp[i]=false;
		else mp[i]=true;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	printf("%d",ans<sb?ans:sb);
	return 0;
}


#include<stdio.h>
#include<string.h>
int R,B,ans;
char shit[101000];
bool mp[101000];
int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",shit+1);
	for(int i=1;i<=n;i++)
	{
		if(shit[i]=='b')mp[i]=false;
		else mp[i]=true;
		if(i==1)continue;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	int sb=ans;
	mp[1]=!mp[1];
	ans=1;
	for(int i=2;i<=n;i++)
	{
		if(shit[i]=='b')mp[i]=false;
		else mp[i]=true;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	printf("%d",ans<sb?ans:sb);
	return 0;
}


#include<stdio.h>
#include<string.h>
int R,B,ans;
char shit[101000];
bool mp[101000];
int n;
int main()
{
	scanf("%d\n",&n);
	scanf("%s",shit);
	int lens=strlen(shit);
	for(int i=0;i<lens;i++)
	{
		if(shit[i]=='r')
			mp[i]=false;
		else
			mp[i]=true;
		if(!i)continue;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else if(!mp[i])
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


#include<stdio.h>
#include<string.h>
int R,B,ans;
char shit[101000];
bool mp[101000];
int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",shit+1);
	for(int i=1;i<=n;i++)
	{
		if(shit[i]=='r')mp[i]=false;
		else mp[i]=true;
		if(i==1)continue;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else if(!mp[i])
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


#include<stdio.h>
#include<string.h>
int R,B,ans;
char shit[10100];
bool mp[10100];
int n;
int main()
{
	scanf("%d\n",&n);
	scanf("%s",shit);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	int lens=strlen(shit);
	/*for(int i=0;i<lens;i++)
	{
	if(shit[i]=='r')R++;
	else B++;
	}*/
	for(int i=0;i<lens;i++)
	{
		if(shit[i]=='r')
			mp[i]=false;
		else
			mp[i]=true;
		if(!i)continue;
		if(mp[i]^mp[i-1])continue;
		else
		{
			if(mp[i])
			{
				if(R)R--;
				else
				{
					ans++;
					B++;
				}
				mp[i]=false;
			}
			else if(!mp[i])
			{
				if(B)B--;
				else
				{
					ans++;
					R++;
				}
				mp[i]=true;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


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

int main(){

    int n,cntr=0,cntb=0,cntrr=0,cntbb=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){

                    if(i%2 == 0){
                        if(str[i] == 'r') cntr++;else cntb++;
                    }else{
                        if(str[i] == 'r') cntrr++;else cntbb++;
                    }
                }//cout << cntr << " " << cntrr << " " << cntb << " " << cntbb << endl;
                cout << min (max(cntr,cntrr),max(cntb,cntbb)) << endl;
return 0;
}


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

int main(){

    int n,cntr=0,cntb=0,cntrr=0,cntbb=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){

                    if(i%2 == 0){
                        if(str[i] == 'r') cntr++;else cntb++;
                    }else{
                        if(str[i] == 'r') cntrr++;else cntbb++;
                    }
                }//cout << cntr << " " << cntrr << " " << cntb << " " << cntbb << endl;
                cout << min (max(cntr,cntb),max(cntrr,cntbb)) << endl;
return 0;
}


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

int main(){

    int n,cntr=0,cntb=0,cntrr=0,cntbb=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){

                    if(i%2 == 0){
                        if(str[i] == 'r') cntr++;else cntb++;
                    }else{
                        if(str[i] == 'r') cntrr++;else cntbb++;
                    }
                }cout << cntr << " " << cntrr << " " << cntb << " " << cntbb << endl;
                cout << min (max(cntb,cntrr),max(cntr,cntrr)) << endl;
return 0;
}


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

int main(){

    int n,cnt=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){
                    if(str[i] != temp){ cnt++; str[i+1] = str[i];}
                    if(temp == 'r') temp = 'b';
                    else temp = 'r';
                }cout << cnt << endl;
return 0;
}


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

int main(){

    int n,cntr=0,cntb=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){
                    if(str[i] != temp){if(temp == 'r') cntr++;else cntb++;}
                    if(temp == 'r') temp = 'b';
                    else temp = 'r';
                }cout << max (cntr,cntb) << endl;
return 0;
}


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

int main(){

    int n,cntr=0,cntb=0,cntrr=0,cntbb=0;
    string str;
        cin>>n;
        cin>>str;
            char temp = str[0];

                for(int i=0; i<n; i++){

                    if(i%2 == 0){
                        if(str[i] == 'r') cntr++;else cntb++;
                    }else{
                        if(str[i] == 'r') cntrr++;else cntbb++;
                    }
                }//cout << cntr << " " << cntrr << " " << cntb << " " << cntbb << endl;
                cout << min (max(cntb,cntrr),max(cntr,cntbb)) << endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXM 5000
#define MAXP 666666
#define MAX 10000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
int a[100000+10];
char aa[100000+10];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",aa);
    for(int i=0;i<n;i++)
    {

        if(aa[i]=='r') a[i+1]=1;
        else a[i+1]=0;
    }

    long long ans=0;

    for(int i=1;i<n;i++)
    {
       if(i==n-1) {
        if(a[i]==a[n])ans++;
        continue ;
       }
        if(a[i]!=a[i+1]) continue;
        else {
            if(a[i+2]!=a[i]){
            if(i==1&&a[i+3]==a[i])  {

                if(a[i]) a[i]=0;
                else a[i]=1;
                    ans++;
            }
            else {
                if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                      if(a[i+2]) a[i+2]=0;
                else a[i+2]=1;
                ans++;
            }
            }
            else {
                    if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                ans++;
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXM 5000
#define MAXP 666666
#define MAX 10000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
int a[100000+10];
char aa[100000+10];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",aa);
    for(int i=0;i<n;i++)
    {

        if(aa[i]=='r') a[i+1]=1;
        else a[i+1]=0;
    }

    long long ans=0;

    for(int i=1;i<n;i++)
    {
       if(i==n-1) {

        if(a[i]==a[n])ans++;
        continue ;
       }
        if(a[i]!=a[i+1]) continue;
        else {
            if(a[i+2]!=a[i]){
                if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                      if(a[i+2]) a[i+2]=0;
                else a[i+2]=1;
                ans++;

            }
            else {
                    if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                ans++;
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXM 5000
#define MAXP 666666
#define MAX 10000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
int a[100000+10];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char x;
        scanf("%c",&x);
        if(x=='r') a[i]=1;
        else a[i]=0;
    }
    long long ans=0;
    for(int i=1;i<n;i++)
    {
       if(i==n-1) {
        if(a[i]==a[n]) ans++;
        continue ;
       }
        if(a[i]!=a[i+1]) continue;
        else {
            if(a[i+2]!=a[i]){
                if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                      if(a[i+2]) a[i+2]=0;
                else a[i+2]=1;
                ans++;

            }
            else {
                    if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                ans++;
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}


#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int getans(string s)
{
	int len=s.length();
	int cnt=1;
	int ans=0;
	for(int i=0;i<len;i++)if(s[i]=='r')s[i]=0;else s[i]=1;
	for(int i=1;i<len;i++)
	{
		if(s[i]==s[i-1])cnt++;
		else cnt=1;
		if(cnt==3)ans++,cnt=1,s[i-1]=!s[i-1];
		if(cnt==2&&s[i+1]!=s[i])ans++,swap(s[i+1],s[i]);
		else if(cnt==2&&i==len-1)ans++;
	}
	return ans;
}
int main()
{
	int n;
	string s,s1;
	while(cin>>n>>s)
	{
		s1=s;
		for(int i=0;i<n;i++)s1[i]=s[n-1-i];
		int ans=getans(s);
		ans=min(ans,getans(s1));
		cout<<ans<<endl;
	}
}

Download as text


#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int getans(string s)
{
	int len=s.length();
	int cnt=1;
	int ans=0;
	for(int i=0;i<len;i++)if(s[i]=='r')s[i]=0;else s[i]=1;
	for(int i=1;i<len;i++)
	{
		if(s[i]==s[i-1])cnt++;
		else cnt=1;
		if(cnt==3)ans++,cnt=1,s[i-1]=!s[i-1];
		if(cnt==2&&s[i+1]!=s[i])ans++,swap(s[i+1],s[i]);
		else if(cnt==2&&i==len-1)ans++;
	}
	return ans;
}
int main()
{
	int n;
	string s,s1;
	while(cin>>n>>s)
	{
		s1=s;
		for(int i=0;i<n;i++)s1[i]=s[n-1-i];
		int ans=getans(s);
		ans=min(ans,getans(s1));
		cout<<ans<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXM 5000
#define MAXP 666666
#define MAX 10000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
int a[100000+10];
char aa[100000+10];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",aa);
    for(int i=0;i<n;i++)
    {

        if(aa[i]=='r') a[i+1]=1;
        else a[i+1]=0;
    }

    long long ans=0;

    for(int i=1;i<n;i++)
    {
       if(i==n-1) {
        if(a[i]==a[n])ans++;
        continue ;
       }
        if(a[i]!=a[i+1]) continue;
        else {
            if(a[i+2]!=a[i]){
            if(i==1)  {
                if(a[i]) a[i]=0;
                else a[i]=1;
                    ans++;
            }
            else {
                if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                      if(a[i+2]) a[i+2]=0;
                else a[i+2]=1;
                ans++;
            }
            }
            else {
                    if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                ans++;
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXM 5000
#define MAXP 666666
#define MAX 10000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
int a[100000+10];
char aa[100000+10];
int main()
{ while(1){
    int n;
    scanf("%d",&n);
    scanf("%s",aa);
    for(int i=0;i<n;i++)
    {

        if(aa[i]=='r') a[i+1]=1;
        else a[i+1]=0;
    }

    long long ans=0;

    for(int i=1;i<n;i++)
    {
       if(i==n-1) {
        if(a[i]==a[n])ans++;
        continue ;
       }
        if(a[i]!=a[i+1]) continue;
        else {
            if(a[i+2]!=a[i]){
            if(i==1&&a[i+3]==a[i])  {

                if(a[i]) a[i]=0;
                else a[i]=1;
                    ans++;
            }
            else {
                if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                      if(a[i+2]) a[i+2]=0;
                else a[i+2]=1;
                ans++;
            }
            }
            else {
                    if(a[i+1]) a[i+1]=0;
                else a[i+1]=1;
                ans++;
            }
        }

    }

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


#include<cstdio>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define For(i,N) for(int i=1;i<=N;i++)
#define Rep(i,N) for(int i=0;i<N;i++)
#define LL long long

using namespace std;

int N,M,T;
char A[100011];

int main()
{

	cin>>N;
	scanf("%s",A+1);
	int aa=0,a=0,b=0,bb=0;
	int ans=0x7fffffff;

	for(int i=1;i<=N;i++)
	{
		if(i%2==1 && A[i]!='r')
		{
			aa++;
		}
		if(i%2==0 && A[i]!='b')
		{
			bb++;
		}
	}

	if(N&1)
	{
		a=N/2;a++;
		b=N/2;
	}
	else {
		a=N/2;
		b=N/2;
	}
	aa=a-aa;
	bb=b-bb;
	ans=min(ans,max(aa,bb));
	aa=bb=0;
	for(int i=1;i<=N;i++)
	{
		if(i%2==1 && A[i]!='b')
		{
			bb++;
		}
		if(i%2==0 && A[i]!='r')
		{
			aa++;
		}
	}
	if(N&1)
	{
		a=N/2;
		b=N/2;b++;
	}
	else {
		a=N/2;
		b=N/2;
	}

	aa=a-aa;
	bb=b-bb;
	ans=min(ans,max(aa,bb));

    cout<<ans<<endl;

	return 0;

}


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

string S;

int main()
{
    int N;
    cin >> N >> S;

    int oddR = 0, evenR = 0, oddB = 0, evenB = 0;

    for(int i=0; i<N; i++)
    {
        if(i%2)
        {
            if(S[i]=='r')
                oddR++;
            else
                oddB++;
        }
        else
        {
            if(S[i]=='r')
                evenR++;
            else
                evenB++;
        }
    }

    int oddRevenB = max(oddB, evenR), oddBevenR = max(oddR, evenB);

    cout << min(oddBevenR, oddRevenB) << endl;

    return 0;
}


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

char S[100005];

int main()
{
    int N;
    scanf("%d %s", &N, S);

    int b = 0, r = 0;

    for(int i=0; i<N; i++)
    {
        if(S[i]=='b')
            b++;
        else
            r++;
    }

    int ans = 0;

    if(N%2)
        ans += abs(b-r)-1;
    else
        ans += abs(b-r);

    ans/=2;

    int tmp1 = 0, tmp2 = 0, ok1 = ans, ok2 = ans;

        for(int i=0; i<N; i++)
        {
            if(i%2 && S[i]=='b')
            {
                if(ok1 && b>r)
                    ok1--;
                else
                    tmp1++;
            }
            else if(i%2==0 && S[i]=='r')
            {
                if(ok1 && b<r)
                    ok1--;
                else
                    tmp1++;
            }
        }

        for(int i=0; i<N; i++)
        {
            if(i%2 && S[i]=='r')
            {
                if(ok2 && r>b)
                    ok2--;
                else
                    tmp2++;
            }
            else if(i%2==0 && S[i]=='b')
            {
                if(ok2 && r<b)
                    ok2--;
                else
                    tmp2++;
            }
        }

        ans += min(tmp1, tmp2)/2;

    printf("%d\n", ans);

    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

int main(){
    int n;
    char s[100005];
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> s[i];
    int count = 0;
    for(int i = 1; i < n; i++){
    	if(s[i] - s[i-1] != 0)
    		continue;

		if(i < n-1){
	   			if(s[i+1] - s[i] > 0){
	   				s[i+1] = 'b';
	   				s[i] = 'r';
	   			}
	   			else if(s[i+1] - s[i] < 0){
	   				s[i+1] = 'r';
	   				s[i] = 'b';
	   			}
	   			else{
	   				if(s[i] == 'b')
	   					s[i] = 'r';
	   				else
	   					s[i] = 'b';
	   			}
		}
		count++;
	}
	cout << count << endl;
	return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

int main(){
    int n;
    char s[100005];
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> s[i];
    int count = 0;

    for(int i = 1; i < n; i++){
    	if(s[i] - s[i-1] != 0)
    		continue;
		if(i < n-1){
				if(s[i-1] != s[i+1])
    				s[i-1] = s[i+1];
	   			else if(s[i+1] - s[i] > 0){
	   				s[i+1] = 'b';
	   				s[i] = 'r';
	   			}
	   			else if(s[i+1] - s[i] < 0){
	   				s[i+1] = 'r';
	   				s[i] = 'b';
	   			}
	   			else{
	   				if(s[i] == 'b')
	   					s[i] = 'r';
	   				else
	   					s[i] = 'b';
	   			}
		}
		count++;
	}
	cout << count << endl;
	return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

int main(){
    int n;
    cin >> n;
    char s[100005];
    int oddr=0, ob=0, er=0, eb=0;
    for(int i = 0; i < n; i++){
    	cin >> s[i];
    	if(i % 2){
    		if(s[i] == 'r')
    			oddr++;
    		else
    			ob++;
    	}
    	else{
    		if(s[i] == 'r')
    			er++;
    		else
    			eb++;
    	}
    }
    cout << min(max(oddr, eb), max(ob, er)) << endl;
	return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    for(int i = 1; i < n; i++){
    	if(s[i] - s[i-1] != 0)
    		continue;

		if(i < n-1){
	   			if(s[i+1] - s[i] > 0){
	   				s[i+1] = 'b';
	   				s[i] = 'r';
	   			}
	   			else if(s[i+1] - s[i] < 0){
	   				s[i+1] = 'r';
	   				s[i] = 'b';
	   			}
	   			else{
	   				if(s[i] == 'b')
	   					s[i] = 'r';
	   				else
	   					s[i] = 'b';
	   			}
		}
		count++;
	}
	cout << count << endl;
	return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

int main(){
    int n;
    char s[100005];
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> s[i];
    int count = 0;

    for(int i = 1; i < n; i++){
    	if(s[i] - s[i-1] != 0)
    		continue;
		if(i < n-1){
				if(i == 1 && s[i] == s[i-1] && s[i-1] != s[i+1])
    				s[i-1] = s[i+1];
	   			else if(s[i+1] - s[i] > 0){
	   				s[i+1] = 'b';
	   				s[i] = 'r';
	   			}
	   			else if(s[i+1] - s[i] < 0){
	   				s[i+1] = 'r';
	   				s[i] = 'b';
	   			}
	   			else{
	   				if(s[i] == 'b')
	   					s[i] = 'r';
	   				else
	   					s[i] = 'b';
	   			}
		}
		count++;
	}
	cout << count << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <queue>
#define N 100001

using namespace std;

char instr[N];

int n;
int count(char base);

int main(){

	cin >> n >> instr;

	cout << min(count('r'), count('b')) << endl;

	return 0;
}

int count(char base){

	int base_bf = 0;
	int other_bf = 0;
	int sum = 0;
	for (int i = 0; i < n; i++ )
	{
		if ( i % 2 && instr[i] == base )
		{
			if ( other_bf )
			{
				other_bf--;
				sum++;
			}
			else
				base_bf++;
		}
		else
		if ( i % 2 == 0 && instr[i] != base )
		{
			if ( base_bf )
			{
				base_bf--;
				sum++;
			}
			else
				other_bf++;
		}
	}

	return sum + other_bf + base_bf;
}


#include <iostream>
#define N 100000
using namespace std;

char instr[N+2];
struct cr{
    int odd;
    int even;
};

    cr r;
    cr b;

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

    for(int i = 0; i < n; i++ )
    {
        if ( instr[i] == 'r' )
        {
            if ( i % 2 )
                r.odd++;
            else
                r.even++;
        }
        else
        {
            if ( i % 2 )
                b.odd++;
            else
                b.even++;
        }
    }

    int r_big = max(r.even, r.odd);
    int b_big = max(b.even, b.odd);

    int r_cand = r.even > r.odd ? 0 : 1;
    int b_cand = b.even > b.odd ? 0 : 1;

    char even_pos;

    if ( r_big > b_big )
    {
        if ( r_cand == 0 )
        {
            even_pos = 'r';
        }
        else
            even_pos = 'b';
    }
    else
    {
        if ( b_cand == 0 )
            even_pos = 'b';
        else
            even_pos = 'r';
    }

    int ops = 0;
    for ( int i = 0; i < n; i++ )
    {
        if ( i % 2 == 0 && instr[i] != even_pos )
        {
            if ( i+1 < n && instr[i+1] == even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos;
                ops++;
            }
        }
        else
        if ( (i % 2) && instr[i] == even_pos )
        {
            if ( i+1 < n && instr[i+1] != even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos == 'r' ? 'b' : 'r';
                ops++;
            }
        }
    }

    cout << ops << endl;

    return 0;

}


#include <iostream>
#define N 100000
using namespace std;

char instr[N+2];
struct cr{
    int odd;
    int even;
};

    cr r;
    cr b;

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

    for(int i = 0; i < n; i++ )
    {
        if ( instr[i] == 'r' )
        {
            if ( i % 2 )
                r.odd++;
            else
                r.even++;
        }
        else
        {
            if ( i % 2 )
                b.odd++;
            else
                b.even++;
        }
    }

    int r_big = max(r.even, r.odd);
    int b_big = max(b.even, b.odd);

    int r_cand = r.even >= r.odd ? 0 : 1;
    int b_cand = b.even >= b.odd ? 0 : 1;

    char even_pos;

    if ( r_big > b_big )
    {
        if ( r_cand == 0 )
        {
            even_pos = 'r';
        }
        else
            even_pos = 'b';
    }
    else
    {
        if ( b_cand == 0 )
            even_pos = 'b';
        else
            even_pos = 'r';
    }

    int ops = 0;
    for ( int i = 0; i < n; i++ )
    {
        if ( i % 2 == 0 && instr[i] != even_pos )
        {
            if ( i+1 < n && instr[i+1] == even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos;
                ops++;
            }
        }
        else
        if ( (i % 2) && instr[i] == even_pos )
        {
            if ( i+1 < n && instr[i+1] != even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos == 'r' ? 'b' : 'r';
                ops++;
            }
        }
    }

    cout << ops << endl;

    return 0;

}


#include <iostream>
#define N 100000
using namespace std;

char instr[N+2];
struct cr{
    int odd;
    int even;
};

    cr r;
    cr b;

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

    for(int i = 0; i < n; i++ )
    {
        if ( instr[i] == 'r' )
        {
            if ( i % 2 )
                r.odd++;
            else
                r.even++;
        }
        else
        {
            if ( i % 2 )
                b.odd++;
            else
                b.even++;
        }
    }

    int r_big = max(r.even, r.odd);
    int b_big = max(b.even, b.odd);

    int r_cand = r.even > r.odd ? 0 : r.even < r.odd ? 1 : 2;
    int b_cand = b.even > b.odd ? 0 : b.even < b.odd ? 1 : 2;

    char even_pos;

    if ( r_big > b_big )
    {
        if ( r_cand == 0 )
        {
            even_pos = 'r';
        }
        else
        if ( r_cand == 1)
            even_pos = 'b';
        else
        {
            if ( b_cand == 0 )
                even_pos = 'b';
            else
            if ( b_cand == 1 )
                even_pos = 'r';
            else
                even_pos = 'r';
        }
    }
    else
    {
        if ( b_cand == 0 )
            even_pos = 'b';
        else
        if ( b_cand == 1)
            even_pos = 'r';
        else
        {
            if ( r_cand == 0 )
                even_pos = 'r';
            else
            if ( r_cand == 1 )
                even_pos = 'b';
            else
                even_pos = 'b';
        }
    }

    int ops = 0;
    for ( int i = 0; i < n; i++ )
    {
        if ( i % 2 == 0 && instr[i] != even_pos )
        {
            if ( i+1 < n && instr[i+1] == even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos;
                ops++;
            }
        }
        else
        if ( (i % 2) && instr[i] == even_pos )
        {
            if ( i+1 < n && instr[i+1] != even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos == 'r' ? 'b' : 'r';
                ops++;
            }
        }
    }

    cout << ops << endl;

    return 0;

}


#include <iostream>
#include <algorithm>
#define N 100001

using namespace std;

char instr[N];

int n;
int count(char base);

int main(){

	cin >> n >> instr;

	cout << min(count('r'), count('b')) << endl;

	return 0;
}

int count(char base){

	int sum = 0;
	for (int i = 0; i < n; i++ )
	{
		if ( i % 2 && instr[i] == base )
		{
			if ( i+1 < n && instr[i+1] != base )
			{
				i++;
			}

			sum++;
		}
		else
		if ( i % 2 == 0 && instr[i] != base )
		{
			if ( i+1 < n && instr[i+1] == base )
			{
				i++;
			}

			sum++;
		}
	}

	return sum;
}


#include <iostream>
#include <algorithm>
#include <queue>
#define N 100001

using namespace std;

char instr[N];

int n;
int count(char base);

int main(){

	cin >> n >> instr;

	cout << min(count('r'), count('b')) << endl;

	return 0;
}

int count(char base){

	int base_bf = 0;
	int other_bf = 0;
	int sum = 0;
	for (int i = 0; i < n; i++ )
	{
		if ( i % 2 && instr[i] == base )
		{
			if ( other_bf )
			{
				other_bf--;
				sum++;
			}
			else
				base_bf++;
		}
		else
		if ( i % 2 == 0 && instr[i] != base )
		{
			if ( base_bf )
			{
				base_bf--;
				sum++;
			}
			else
				other_bf++;
		}
	}

	return sum + (max(other_bf, base_bf) - min(other_bf, base_bf));
}


#include <iostream>
#define N 100000
using namespace std;

char instr[N+2];
struct cr{
    int odd;
    int even;
};

    cr r;
    cr b;

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

    for(int i = 0; i < n; i++ )
    {
        if ( instr[i] == 'r' )
        {
            if ( i % 2 )
                r.odd++;
            else
                r.even++;
        }
        else
        {
            if ( i % 2 )
                b.odd++;
            else
                b.even++;
        }
    }

    char even_pos = r.even > b.even ? 'r' : 'b';

    int ops = 0;
    for ( int i = 0; i < n; i++ )
    {
        if ( i % 2 == 0 && instr[i] != even_pos )
        {
            if ( i+1 < n && instr[i+1] == even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos;
                ops++;
            }
        }
        else
        if ( (i % 2) && instr[i] == even_pos )
        {
            if ( i+1 < n && instr[i+1] != even_pos )
            {
                char tmp = instr[i];
                instr[i] = instr[i+1];
                instr[i+1] = tmp;
                ops++;
            }
            else
            {
                instr[i] = even_pos == 'r' ? 'b' : 'r';
                ops++;
            }
        }
    }

    cout << ops << endl;

    return 0;

}


#include <bits/stdc++.h>
	int A[200000],ok, k = 0,t = 0, N, B[200000];
	int x = 0, y = 0;
using namespace std;
int main () {
	char ch;
	cin >> N;
	for(int i=0; i<N; i++) {
		cin >> ch;
		if(ch == 'b') A[i] = B[i] = 1, x++;
		else A[i] = B[i] = 0, y++;
	}
	for(int i=0; i<N; i++) {
		ok = true;
		if(A[i] != i%2) {
			for(int j=i+1; j<N; j++) {
				if(A[j] != A[i] && A[j]!=j%2) {
					swap(A[i],A[j]);
					ok = false;
					break;
				}
			}
			k++;
		}
	}
	for(int i=0; i<N; i++) {
		ok = true;
		if(B[i] == i%2) {
			for(int j=i+1; j<N; j++) {
				if(B[j] != B[i] && B[j]==j%2) {
					swap(B[i],B[j]);
					ok = false;
					break;
				}
			}
			t++;
		}
	}

	cout << min(k,t) << endl;
//	for(int i=0; i<N; i++)
//		cout << A[i];
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

main()
{
	int n,k;
	cin>>n>>k;

	vector<string> vec;
	string s;

	for(int i=0;i<n;i++)
	{
		cin>>s;
		vec.push_back(s);
	}
	int maxval=-1,v,h,ans,l,r,t,b;
	int maxx=-1;
	int maxy=-1;
	for(int x=0;x<n;x++)
	{
		for(int y=0;y<n;y++)
		{
			l=0;
			r=0;
			t=0;
			b=0;
			ans=0;
			if(vec[x][y]=='.')
			{
				for(int i=x;i>=0;i--)
				{
					if(vec[i][y]=='#')
						break;

					t++;
				}

				for(int i=x+1;i<n;i++)
				{
					if(vec[i][y]=='#')
						break;

					b++;
				}

				for(int i=y;i>=0;i--)
				{
					if(vec[x][i]=='#')
						break;

					l++;
				}

				for(int i=y+1;i<n;i++)
				{
					if(vec[x][i]=='#')
						break;

					r++;
				}

				if(t+b>=k)
				{

					for(int c=max(x-t+1,x-k+1);c<=x;c++)
					{
						if(c+k-1<=x+b)
							ans++;
					}
				}

				if(l+r>=k)
				{

					for(int c=max(y-l+1,y-k+1);c<=y;c++)
					{
						if(c+k-1<=y+r)
							ans++;
					}
				}

				//cout<<x<<" "<<y<<" : "<<t<<" "<<b<<" "<<l<<" "<<r<<" "<<ans<<endl;
				if(ans>maxval)
				{
					maxx=x;
					maxy=y;
					maxval=ans;
				}
			}
//			else if(vec[x][y]=='#')
//				cout<<"#"<<" ";
		}
		//cout<<endl;
	}

	cout<<maxx+1<<" "<<maxy+1<<endl;

}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

main()
{
	int n,k;
	cin>>n>>k;

	vector<string> vec;
	string s;

	for(int i=0;i<n;i++)
	{
		cin>>s;
		vec.push_back(s);
	}
	int maxval=-1,v,h,ans,l,r,t,b;
	int maxx=-1;
	int maxy=-1;
	for(int x=0;x<n;x++)
	{
		for(int y=0;y<n;y++)
		{
			l=0;
			r=0;
			t=0;
			b=0;
			ans=0;
			if(vec[x][y]=='.')
			{
				for(int i=x;i>=0;i--)
				{
					if(vec[i][y]=='#')
						break;

					t++;
				}

				for(int i=x+1;i<n;i++)
				{
					if(vec[i][y]=='#')
						break;

					b++;
				}

				for(int i=y;i>=0;i--)
				{
					if(vec[x][i]=='#')
						break;

					l++;
				}

				for(int i=y+1;i<n;i++)
				{
					if(vec[x][i]=='#')
						break;

					r++;
				}

				if(t+b>=k)
				{

					for(int c=max(x-t+1,x-k+1);c<=x;c++)
					{
						if(c+k-1<=x+b)
							ans++;
					}
				}

				if(l+r>=k)
				{

					for(int c=max(y-l+1,y-k+1);c<=y;c++)
					{
						if(c+k-1<=y+r)
							ans++;
					}
				}

				//cout<<x<<" "<<y<<" : "<<t<<" "<<b<<" "<<l<<" "<<r<<" "<<ans<<endl;
				if(ans>maxval)
				{
					maxx=x;
					maxy=y;
					maxval=ans;
				}
			}
//			else if(vec[x][y]=='#')
//				cout<<"#"<<" ";
		}
		//cout<<endl;
	}

	if(n==1 && k==1)
		cout<<1<<" "<<1<<endl;
	else if(maxx!=-1 && maxy!=-1)
		cout<<maxx+1<<" "<<maxy+1<<endl;
	else
		cout<<1<<" "<<1<<endl;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int r=n;
    int c=n;
    int cnt=0;
    int mxcnt=0;
    int rx,ry;
    int tx=0,ty=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    cnt=0;
                    //cnt++;
                    tx=i;ty=j;
                    int tcnt=0;
                    int sz=1;
                    for(int k=j+1;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            tcnt++;
                        }
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;
                    tcnt=0;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    sz=1;
                    tcnt=0;
                    //cout<<cnt<<" ";
                    for(int k=i+1;k<n;k++){
                        if(str[k][j]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                                break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;tcnt=0;
                    for(int k=i-1;k>0;k--){
                        if(str[k][j]=='.')
                            cnt++;
                        else
                            break;

                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;

                    //cout<<cnt<<" from "<<i+1<<" "<<j+1<<endl;
                   // cout<<i+1<<" "<<j+1<<endl;
                    if(cnt>mxcnt){
                        mxcnt=cnt;
                        rx=i;
                        ry=j;
                    }
            }
        }
    }
    if(mxcnt>0)
        cout<<rx+1<<" "<<ry+1<<endl;
    else
        cout<<tx+1<<" "<<ty+1<<endl;
    return 0;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int r=n;
    int c=n;
    int cnt=0;
    int mxcnt=0;
    int rx,ry;
    int tx=0,ty=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    cnt=0;
                    //cnt++;
                    tx=i;ty=j;
                    int tcnt=0;
                    int sz=1;
                    for(int k=j+1;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            tcnt++;
                        }
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    //if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;
                    tcnt=0;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    //if(sz==p)
                        cnt=cnt+tcnt;
                    sz=1;
                    tcnt=0;
                    //cout<<cnt<<" ";
                    for(int k=i+1;k<n;k++){
                        if(str[k][j]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                                break;
                    }
                    //if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;tcnt=0;
                    for(int k=i-1;k>0;k--){
                        if(str[k][j]=='.')
                            cnt++;
                        else
                            break;

                        sz++;
                        if(sz==p)
                            break;
                    }
                    //if(sz==p)
                        cnt=cnt+tcnt;

                    //cout<<cnt<<" from "<<i+1<<" "<<j+1<<endl;
                   // cout<<i+1<<" "<<j+1<<endl;
                    if(cnt>mxcnt){
                        mxcnt=cnt;
                        rx=i;
                        ry=j;
                    }
            }
        }
    }
    if(mxcnt>0)
        cout<<rx+1<<" "<<ry+1<<endl;
    else
        cout<<tx+1<<" "<<ty+1<<endl;
    return 0;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int r=n;
    int c=n;
    int cnt=0;
    int mxcnt=0;
    int rx=0,ry=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    cnt=0;
                    //cnt++;
                    rx=i;
                    ry=j;
                    int tcnt=0;
                    int sz=1;
                    for(int k=j+1;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            tcnt++;
                        }
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;
                    tcnt=0;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    sz=1;
                    tcnt=0;
                    //cout<<cnt<<" ";
                    for(int k=i+1;k<n;k++){
                        if(str[k][j]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                                break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;tcnt=0;
                    for(int k=i-1;k>0;k--){
                        if(str[k][j]=='.')
                            cnt++;
                        else
                            break;

                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;

                    //cout<<cnt<<" from "<<i+1<<" "<<j+1<<endl;
                   // cout<<i+1<<" "<<j+1<<endl;
                    if(cnt>mxcnt){
                        mxcnt=cnt;
                        rx=i;
                        ry=j;
                    }
            }
        }
    }
    cout<<rx+1<<" "<<ry+1<<endl;
    return 0;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int arr[110][110];
    for(int i=0;i<110;i++){
        for(int j=0;j<110;j++){
            arr[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    int sz=0;
                    for(int k=j;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            sz++;
                        }
                        else
                            break;

                        if(sz==p)
                            break;
                    }
                    if(sz==p){
                        for(int k=j;k<j+sz;k++){
                            arr[i][k]++;
                        }
                    }
                    /*sz=1;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            sz++;
                        else
                            break;
                        if(sz==p)
                            break;
                    }
                    if(sz==p){
                        for(int k=j;k>j-sz;k--){
                            arr[i][k]++;
                        }
                    }*/
                    sz=0;
                    for(int k=i;k<n;k++){
                        if(str[k][j]=='.')
                            sz++;
                        else
                            break;
                        if(sz==p)
                            break;
                    }
                    if(sz==p){
                        for(int k=i;k<i+sz;k++){
                            arr[k][j]++;
                        }
                    }
                   /* sz=0;
                    for(int k=i;k>=0;k--){
                        if(str[k][j]=='.')
                            sz++;
                        else
                            break;
                        if(sz==p)
                            break;
                    }
                    if(sz==p){
                        for(int k=i;k>i-sz;k--){
                            arr[k][j]++;
                        }
                    }*/
            }
        }
    }
    int mxcnt=0;
    int rx,ry;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(arr[i][j]>mxcnt){
                mxcnt=arr[i][j];
                rx=i;
                ry=j;
            }
            //cout<<arr[i][j];
        }
       // cout<<endl;
    }
        cout<<rx+1<<" "<<ry+1<<endl;
    return 0;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int r=n;
    int c=n;
    int cnt=0;
    int mxcnt=0;
    int rx=0,ry=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    cnt=0;
                    //cnt++;
                    int tcnt=0;
                    int sz=1;
                    for(int k=j+1;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            tcnt++;
                        }
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;
                    tcnt=0;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    sz=1;
                    tcnt=0;
                    //cout<<cnt<<" ";
                    for(int k=i+1;k<n;k++){
                        if(str[k][j]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                                break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;tcnt=0;
                    for(int k=i-1;k>0;k--){
                        if(str[k][j]=='.')
                            cnt++;
                        else
                            break;

                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;

                    //cout<<cnt<<" from "<<i+1<<" "<<j+1<<endl;
                   // cout<<i+1<<" "<<j+1<<endl;
                    if(cnt>mxcnt){
                        mxcnt=cnt;
                        rx=i;
                        ry=j;
                    }
            }
        }
    }
    cout<<rx+1<<" "<<ry+1<<endl;
    return 0;
}


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

int main()
{
    int n,p;
    cin>>n>>p;
    char str[110][110];

    getchar();
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    int r=n;
    int c=n;
    int cnt=0;
    int mxcnt=0;
    int rx,ry;
    int tx,ty;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(str[i][j]=='.'){
                    cnt=0;
                    //cnt++;
                    tx=i;ty=j;
                    int tcnt=0;
                    int sz=1;
                    for(int k=j+1;k<n;k++){ /* side jabo*/
                        if(str[i][k]=='.'){
                            tcnt++;
                        }
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;
                    tcnt=0;
                    for(int k=j-1;k>0;k--){
                        if(str[i][k]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    sz=1;
                    tcnt=0;
                    //cout<<cnt<<" ";
                    for(int k=i+1;k<n;k++){
                        if(str[k][j]=='.')
                            tcnt++;
                        else
                            break;
                        sz++;
                        if(sz==p)
                                break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;
                    //cout<<cnt<<" ";
                    sz=1;tcnt=0;
                    for(int k=i-1;k>0;k--){
                        if(str[k][j]=='.')
                            cnt++;
                        else
                            break;

                        sz++;
                        if(sz==p)
                            break;
                    }
                    if(sz==p)
                        cnt=cnt+tcnt;

                    //cout<<cnt<<" from "<<i+1<<" "<<j+1<<endl;
                   // cout<<i+1<<" "<<j+1<<endl;
                    if(cnt>mxcnt){
                        mxcnt=cnt;
                        rx=i;
                        ry=j;
                    }
            }
        }
    }
    if(mxcnt>0)
        cout<<rx+1<<" "<<ry+1<<endl;
    else
        cout<<tx+1<<" "<<ty+1<<endl;
    return 0;
}


#include<iostream>
#define MAXN 102

using namespace std;

int table[MAXN][MAXN];
int tableT[MAXN][MAXN],MT[MAXN][MAXN];
int tableL[MAXN][MAXN],ML[MAXN][MAXN];

void PRINT(int n)
{
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)cout << MT[i][j] << " ";
        cout << endl;
    }
}

int main()
{
    int n,k;
    cin >> n >> k;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            char c;cin >> c;
            table[i][j] = c;
        }
    }
    /*top*/
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)
        {
            if(i==0||j==0||i==n+1||j==n+1)tableT[i][j] = 0;
            else if(table[i][j]=='#')tableT[i][j] = 0;
            else tableT[i][j] = tableT[i-1][j]+1;
        }
    }
    for(int i=n+1;i>=0;i--)
        for(int j=0;j<=n+1;j++)
            MT[i][j] = (tableT[i][j]==0)?0:max(MT[i+1][j],tableT[i][j]);
    /*left*/
    for(int j=0;j<=n+1;j++)
    {
        for(int i=0;i<=n+1;i++)
        {
            if(i==0||j==0||i==n+1||j==n+1)tableL[i][j] = 0;
            else if(table[i][j]=='#')tableL[i][j] = 0;
            else tableL[i][j] = tableL[i][j-1]+1;
        }
    }
    for(int j=n+1;j>=0;j--)
        for(int i=0;i<=n+1;i++)
            ML[i][j] = (tableL[i][j]==0)?0:max(ML[i][j+1],tableL[i][j]);

    //PRINT(n);

    /*find*/
    int maxship = 0,ship = 0;
    int pi = 0,pj = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++,ship=0)
        {
            //cout << "ij : " << i << " " << j << endl;
            if(MT[i][j]>=k)
            {
                int top = tableT[i][j]-k>=0?tableT[i][j]-k+1:1;
                int bot = MT[i][j]-tableT[i][j]>=k?tableT[i][j]+k-1:MT[i][j];
                ship += (bot-top+1)-k+1;
                //cout << top << " " << bot << endl;
            }
            if(ML[i][j]>=k)
            {
                int left = tableL[i][j]-k>=0?tableL[i][j]-k+1:1;
                int right = ML[i][j]-tableL[i][j]>=k?tableL[i][j]+k-1:ML[i][j];
                ship += (right-left+1)-k+1;
                //cout << left << " " << right << endl;
            }
            if(ship > maxship)
            {
                maxship = ship;
                pi = i;pj = j;
            }
        }
    }
    //cout << maxship << endl;
    cout << pi << " " << pj;
}


#include<iostream>
#define MAXN 102

using namespace std;

int table[MAXN][MAXN];
int tableT[MAXN][MAXN],MT[MAXN][MAXN];
int tableL[MAXN][MAXN],ML[MAXN][MAXN];

void PRINT(int n)
{
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)cout << MT[i][j] << " ";
        cout << endl;
    }
}

int main()
{
    int n,k;
    cin >> n >> k;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            char c;cin >> c;
            table[i][j] = c;
        }
    }
    /*top*/
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)
        {
            if(i==0||j==0||i==n+1||j==n+1)tableT[i][j] = 0;
            else if(table[i][j]=='#')tableT[i][j] = 0;
            else tableT[i][j] = tableT[i-1][j]+1;
        }
    }
    for(int i=n+1;i>=0;i--)
        for(int j=0;j<=n+1;j++)
            MT[i][j] = (tableT[i][j]==0)?0:max(MT[i+1][j],tableT[i][j]);
    /*left*/
    for(int j=0;j<=n+1;j++)
    {
        for(int i=0;i<=n+1;i++)
        {
            if(i==0||j==0||i==n+1||j==n+1)tableL[i][j] = 0;
            else if(table[i][j]=='#')tableL[i][j] = 0;
            else tableL[i][j] = tableL[i][j-1]+1;
        }
    }
    for(int j=n+1;j>=0;j--)
        for(int i=0;i<=n+1;i++)
            ML[i][j] = (tableL[i][j]==0)?0:max(ML[i][j+1],tableL[i][j]);

    //PRINT(n);

    /*find*/
    int maxship = 0,ship = 0;
    int pi = 1,pj = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++,ship=0)
        {
            //cout << "ij : " << i << " " << j << endl;
            if(MT[i][j]>=k)
            {
                int top = tableT[i][j]-k>=0?tableT[i][j]-k+1:1;
                int bot = MT[i][j]-tableT[i][j]>=k?tableT[i][j]+k-1:MT[i][j];
                ship += (bot-top+1)-k+1;
                //cout << top << " " << bot << endl;
            }
            if(ML[i][j]>=k)
            {
                int left = tableL[i][j]-k>=0?tableL[i][j]-k+1:1;
                int right = ML[i][j]-tableL[i][j]>=k?tableL[i][j]+k-1:ML[i][j];
                ship += (right-left+1)-k+1;
                //cout << left << " " << right << endl;
            }
            if(ship > maxship)
            {
                maxship = ship;
                pi = i;pj = j;
            }
        }
    }
    //cout << maxship << endl;
    cout << pi << " " << pj;
}