stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

	int n,i=0,e=0,w=0,an=1e9,a[300003];

	char c[300003];

	cin>>n;

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

	{

		cin>>c[i];

		a[i]=w;

		w+=c[i]==87;

	}

	for(i=n-1;i>-1;i--)

	{

		an=min(an,a[i]+e);

		e+=c[i]==69;

	}

	cout<<an<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.38802920806353x):
#include<cstdio>

int n,i,e,w,s=1e9,a[1<<19];char c[1<<19];main(){for(scanf("%d\n",&n);i<n;scanf("%c",c+i),a[i]=w,w+=c[i++]==87);for(;i>0;s=s<a[--i]+e?s:a[i]+e,e+=c[i]==69);printf("%d",s);}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

	int n,i=0,e=0,w=0,an=1e9,a[300003];

	char c[300003];

	cin>>n;

	for(;i<n;)

	{

		cin>>c[i];

		a[i]=w;

		w+=c[i++]==87;

	}

	for(i=n-1;i>-1;i--)

	{

		an=min(an,a[i]+e);

		e+=c[i]==69;

	}

	cout<<an<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.38802920806353x):
#include<cstdio>

int n,i,e,w,s=1e9,a[1<<19];char c[1<<19];main(){for(scanf("%d\n",&n);i<n;scanf("%c",c+i),a[i]=w,w+=c[i++]==87);for(;i>0;s=s<a[--i]+e?s:a[i]+e,e+=c[i]==69);printf("%d",s);}
// Slower C++ solution:
#include<iostream>

#include<cmath>

//using namespace std;

int n,i,e,w,s=1e9,a[1<<19];

char c[1<<19];

int main()

{

	for(std::cin>>n;i<n;std::cin>>c[i],a[i]=w,w+=c[i++]==87);

	for(;i>0;s=fmin(s,a[--i]+e),e+=c[i]==69);

	std::cout<<s<<std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.270606065364277x):
#include<cstdio>

int n,i,e,w,s=1e9,a[1<<19];char c[1<<19];main(){for(scanf("%d\n",&n);i<n;scanf("%c",c+i),a[i]=w,w+=c[i++]==87);for(;i>0;s=s<a[--i]+e?s:a[i]+e,e+=c[i]==69);printf("%d",s);}
// Slower C++ solution:
#include "iostream"

#include "algorithm"

#include "string"

#include "vector"

#include "cmath"

#include "bitset"

#include "queue"

#include "functional"

#include "map"

#include "unordered_map"



#define lp(n) for (int i = 0; i < n; i++)

#define LP(n,i) for (int i = 0; i < n; i++)

#define mod 1000000007

#define sp ' '

#define intmax 2147483647

#define llmax 9223372036854775807

#define nya_n "(=^･ω･^=)"

typedef long long ll;

using namespace std;



/*

ll gcd(ll x, ll y) {

	if (y == 0) return x;

	return gcd(y, x%y);

}

ll lcm(ll x, ll y) {

	ll g = gcd(x, y);

	return x / g * y;

}*/



int h, w, pcnt;

char grid[52][52];

int cntgrid[52][52];



int main(){

	cin >> h >> w;

	pcnt = 0;

	lp(w+2) {

		grid[0][i] = '#';

		grid[h + 1][i] = '#';

	}

	lp(h) {

		grid[i + 1][0] = '#';

		grid[i + 1][w + 1] = '#';

	}

	lp(h) {

		LP(w, j) {

			cin >> grid[i + 1][j + 1];

			if (grid[i + 1][j + 1] == '.') {

				pcnt++;

			}

		}

	}

	lp(h + 2) {

		LP(w + 2, j) {

			cntgrid[i][j] = 1000000;

		}

	}

	cntgrid[1][1] = 1;

	lp(pcnt) {

		LP(h, j) {

			LP(w, k) {

				if (grid[j + 1][k + 1] == '.') {

					if (grid[j][k + 1] == '.') {

						cntgrid[j][k + 1] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j][k + 1]);

					}

					if (grid[j + 1][k] == '.') {

						cntgrid[j + 1][k] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 1][k]);

					}

					if (grid[j + 2][k + 1] == '.') {

						cntgrid[j + 2][k + 1] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 2][k + 1]);

					}

					if (grid[j + 1][k + 2] == '.') {

						cntgrid[j + 1][k + 2] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 1][k + 2]);

					}

				}

			}

		}

	}

	if(cntgrid[h][w]==1000000)

		cout << -1 << endl;

	else cout << pcnt - cntgrid[h][w] << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3128704984030874x):
#include <bits/stdc++.h>

using namespace std;



int H,W,g[50][50],cntp;

const int x[4]={0,0,1,-1};

const int y[4]={1,-1,0,0};

char s[50][50];

queue<pair<int,int>>q;



int main()

{

    cin>>H>>W;

    for(int i=0;i!=H;++i){

        for(int j=0;j!=W;++j){

            cin>>s[i][j];

            if(s[i][j]=='.')++cntp;

            g[i][j]=0xe869120;

        }

    }

    q.push(make_pair(0,0));

    g[0][0]=1;

    while(!q.empty()){

        for(int i=0;i!=4;++i){

            if(q.front().first+x[i]!=-1&&q.front().first+x[i]!=H&&q.front().second+y[i]!=-1&&q.front().second+y[i]!=W&&g[q.front().first+x[i]][q.front().second+y[i]]==0xe869120&&s[q.front().first+x[i]][q.front().second+y[i]]=='.'){

                g[q.front().first+x[i]][q.front().second+y[i]]=g[q.front().first][q.front().second]+1;

                q.push(make_pair(q.front().first+x[i],q.front().second+y[i]));

            }

        }

        q.pop();

    }

    if(g[H-1][W-1]==0xe869120)cout<<-1<<endl;

    else cout<<cntp-g[H-1][W-1]<<endl;

    return 0;

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

using namespace std;

#define inf 1000000000

#define INF 1000000000000000

#define ll long long

#define ull unsigned long long

#define M 1000000007

#define P pair<int,int>

#define PLL pair<ll,ll>

#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)

#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)

#define rep(i,n) FOR(i,0,n)

#define rrep(i,n) RFOR(i,n,0)

#define all(a) a.begin(),a.end()

#define IN(a,n) rep(i,n){ cin>>a[i]; }

const int vx[4] = {0,1,0,-1};

const int vy[4] = {1,0,-1,0};

#define PI 3.14159265

#define F first

#define S second

#define int ll



int n,m;

string s[1000];

int r,t;



signed main(){

  cin>>n>>m;

  rep(i,n){

    cin>>s[i];

  }



  rep(i,n){

    rep(j,m){

      if(s[i][j]=='.') r++;

      else t++;

    }

  }



  queue<P> q;

  q.push(P(0,0));

  int c[1000][1000];

  rep(i,1000){

    rep(j,1000){

      c[i][j]=inf;

    }

  }

  c[0][0]=0;

  while(q.size()){

    int a=q.front().F;

    int b=q.front().S;

    q.pop();

    rep(i,4){

      int x=a+vx[i];

      int y=b+vy[i];

      if(!(0<=x&&x<m&&0<=y&&y<n))continue;

      if(s[y][x]=='#') continue;

      if(c[y][x]>c[b][a]+1){

        c[y][x] = c[b][a]+1;

        q.push(P(x,y));

      }

    }

  }



  if(c[n-1][m-1]==inf){

    cout<<-1<<endl;

    return 0;

  }



  cout<<r-1-c[n-1][m-1]<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 9.351525554280986x):


#include<bits/stdc++.h>

using namespace std;

#define inf 1000000000

#define INF 100000000000000

#define ll long long

#define ull unsigned long long

#define M (int)(1e9+7)

#define P pair<int,int>

#define PLL pair<ll,ll>

#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)

#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)

#define rep(i,n) FOR(i,0,n)

#define rrep(i,n) RFOR(i,n,0)

#define all(a) a.begin(),a.end()

#define IN(a,n) rep(i,n){ cin>>a[i]; }

const int vx[4] = {0,1,0,-1};

const int vy[4] = {1,0,-1,0};

#define PI 3.14159265

#define F first

#define S second

#define PB push_back

#define EB emplace_back



int h,w;

char s[100][100];

int t[100][100];

int ans=0;

int main(){

  cin>>h>>w;

  rep(i,h){

    cin>>s[i];

    rep(j,w){

      t[i][j]=inf;

      if(s[i][j]=='.')

        ans++;

    }

  }

  t[0][0]=0;

  queue<P> q;

  q.push(P(0,0));

  while(!q.empty()){

    int a=q.front().F,b=q.front().S;

    q.pop();

    rep(i,4){

      int x=a+vx[i],y=b+vy[i];

      if(!(0<=x&&x<w&&0<=y&&y<h)) continue;

      if(s[y][x]=='.'&&t[y][x]>t[b][a]+1){

        t[y][x]=t[b][a]+1;

        q.push(P(x,y));

      }

    }

  }



  if(t[h-1][w-1]==inf)

    cout<<-1<<endl;

  else

    cout<<ans-1-t[h-1][w-1]<<endl;

}
// Slower C++ solution:
#include <iostream>

#include <cstdlib>

#include <vector>

#include <queue>



using namespace std;

const int INFTY = (1 << 21);



int main(void){

    int H,W;

    cin >> H >> W;



    vector<vector<int> > map(H+2, vector<int>(W+2,'#'));

    vector<vector<int> > s(H*W, vector<int>(H*W, 0));

    vector<int> d(H*W, INFTY);

    char tmp;

    int white_count = 0;



    for(int i=1;i<=H;i++){

        for(int j=1;j<=W;j++){

            cin >> tmp;

            map[i][j] = tmp;

            if(tmp == '.') white_count++;

        }

    }



    for(int i=1;i<=H;i++){

        for(int j=1;j<=W;j++){

            int I = i-1, J = j-1;

            int index  = I*W + J;

            int index_nbh[4];

            index_nbh[0] = (I-1)*W + J; // up

            index_nbh[1] = (I+1)*W + J; // down

            index_nbh[2] = I*W + J-1;   // left

            index_nbh[3] = I*W + J+1;   // right



            if(map[i-1][j] == '.') s[index][index_nbh[0]] = 1;

            if(map[i+1][j] == '.') s[index][index_nbh[1]] = 1;

            if(map[i][j-1] == '.') s[index][index_nbh[2]] = 1;

            if(map[i][j+1] == '.') s[index][index_nbh[3]] = 1;

        }

    }





    queue<int> q;

    q.push(0);

    d[0] = 1;

    int u;

    while( !q.empty()){

        u = q.front(); q.pop();

        for(int v=1;v<(H+1)*(W+1);v++){

            if(s[u][v] == 0) continue;

            if(d[v] != INFTY) continue;

            d[v] = d[u] + 1;

            q.push(v);

        }

    }

    cout << (d[W*H-1] != INFTY ? white_count-d[W*H-1] : (-1) ) << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9850253414695265x):
#include <iostream>

#include <queue>



using namespace std;



const int INFTY = 1e9;

const int HMAX = 100;

const int WMAX = 100;



char grid[HMAX][WMAX];

int dist[HMAX][WMAX];

int di[] = {0,0,1,-1};

int dj[] = {1,-1,0,0};



int H,W;



int bfs(int sx, int sy, int gx, int gy){

    for(int i=1;i<=H;i++){

        for(int j=1;j<=W;j++){

            dist[i][j] = INFTY;

        }

    }



    dist[sx][sy] = 1;

    queue<pair<int,int> > Q;

    Q.push(make_pair(sx,sy));



    while(!Q.empty()){

        auto p = Q.front(); Q.pop();

        int x = p.first;

        int y = p.second;

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

            int nx = x + di[i];

            int ny = y + dj[i];

            if(nx < 1 || nx > H || ny < 1 || ny > W) continue;

            if(nx == gx && ny == gy) return dist[x][y] + 1;

            if(dist[nx][ny] == INFTY && grid[nx][ny] == '.'){

                dist[nx][ny] = dist[x][y] + 1;

                Q.push(make_pair(nx,ny));

            }

        }

    }

    return -1;

}



int main(){

    cin >> H >> W;

    int count = 0;

    for(int i=1;i<=H;i++){

        for(int j=1;j<=W;j++){

            cin >> grid[i][j];

            if(grid[i][j] == '.') count++;

        }

    }



    int ans = bfs(1,1, H,W);



    if(ans == -1){

        cout << -1 << endl;

    }else{

        cout << count - ans << endl;

    }

    return 0;

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

#define re return

#define ll long long

#define ld long double

#define f first

#define s second

#define pi acos(-1)

#define oo (int)1e9

#define OO (ll)1e18

#define EPS 1e-7

#define FX(n) fixed<<setprecision(n)

#define mm(o,k) memset(o,k,sizeof o)

#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

const int maxn=105;

int dx[]={0,0,1,-1};

int dy[]={1,-1,0,0};

int n,m;

char a[maxn][maxn];

map<pair<int,int>,pair<int,int> >p;

map<pair<int,int>,bool >vis;

bool valid(int i,int j){

    re(i>=0&&i<n&&j>=0&&j<m&&a[i][j]=='.');

}

int bfs(){

    int ans=0;

    queue<pair<int,int> >q;

    q.push({0,0});

    p[{0,0}]={-1,-1};

    bool done=false;

    while(q.size()){

        int x=q.front().f;

        int y=q.front().s;

        q.pop();

        if(x==n-1&&y==m-1){done=true;break;}

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

            int xx=x+dx[i],yy=y+dy[i];

            if(vis[{xx,yy}]||!valid(xx,yy))continue;

            vis[{xx,yy}]=true;

            p[{xx,yy}]={x,y};

            q.push({xx,yy});

        }

    }

    if(!done)re -1;

    pair<int,int> temp={n-1,m-1},hna={0,0};

    while(true){

        a[temp.f][temp.s]='#';

        if(temp==hna)break;

        temp=p[temp];

    }

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

        for(int j=0;j<m;++j)

            ans+=a[i][j]=='.';

    re ans;

}

int main()

{

    IO;

    cin >> n >> m;

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

        for(int j=0;j<m;++j)

            cin >> a[i][j];

    cout<<bfs()<<endl;

    re 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1292212017576162x):
#include <bits/stdc++.h>

#define re return

#define ll long long

#define ull unsigned ll

#define ld long double

#define f first

#define s second

#define pi acos(-1)

#define oo (ll)1e9

#define OO (ll)1e18

#define EPS 1e-7

#define FX(n) fixed<<setprecision(n)

#define mm(o,k) memset(o,k,sizeof o)

#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

const int maxn=55;

int n,m;

char a[maxn][maxn];

int dx[]={0,0,1,-1};

int dy[]={1,-1,0,0};

bool vis[maxn][maxn];

bool valid(int x,int y){

    re (x>=0&&y>=0&&x<n&&y<m&&!vis[x][y]&&a[x][y]=='.');

}

int dot;

int bfs(){

    queue<pair<pair<int,int>,int> > q;

    q.push({{0,0},0});

    while(q.size()){

        int x=q.front().f.f;

        int y=q.front().f.s;

        int cost=q.front().s;

        q.pop();

        if(x==n-1&&y==m-1)re dot-(cost+1);

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

            int xx=x+dx[i],yy=dy[i]+y;

            if(valid(xx,yy)){

                q.push({{xx,yy},cost+1});

                vis[xx][yy]=true;

            }

        }

    }

    re -1;

}

int main(){

    IO;

    cin >> n >> m;

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

        for(int j=0;j<m;++j)

            cin >> a[i][j],dot+=a[i][j]=='.';

    cout<<bfs()<<endl;

    re 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <vector>



using namespace std;

int main()

{

    int n; cin >> n;

    string s; char t;

    cin >> t;

    s.push_back(t);

    for( int i = 1; i < n; ++ i )

    {

        cin >> t;

        if( t == s.back() )

            continue;

        else s.push_back(t);

    }

    cout << s.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.268016495477884x):
#include<stdio.h>



int main(){

long n = 0, result=0;

scanf("%d\n", &n);

char s[n];



for(long i = 0; i<n; i++){scanf("%c", &s[i]);}



int temp=0;

for(long i = 0; i<n; ){

    while(1){

    if(s[i]==s[i+1]){

        temp=1;

        i++;

    }else{

        i++;

        break;}

    }

    if(temp){result+=temp;}else{result+=1;}

}

printf("%ld", result);

return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

#include<cstring>

using namespace std;

int n;

string str;

int main()

{

	cin >> n;

	cin >> str;

	int ans = 1;

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

	{

		if (i != 0 && str[i] != str[i - 1])

			ans++;

	}

	cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.236217192629721x):
#include<stdio.h>



int main(){

long n = 0, result=0;

scanf("%d\n", &n);

char s[n];



for(long i = 0; i<n; i++){scanf("%c", &s[i]);}



int temp=0;

for(long i = 0; i<n; ){

    while(1){

    if(s[i]==s[i+1]){

        temp=1;

        i++;

    }else{

        i++;

        break;}

    }

    if(temp){result+=temp;}else{result+=1;}

}

printf("%ld", result);

return 0;

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

#define Mod 1000000007

#define eps 1e-6

#define ll long long

#define INF 0x3f3f3f3f

#define MEM(x, y) memset(x, y, sizeof(x))

#define Maxn 1000000 + 10

using namespace std;

int N;

string S;

int result=0;

int solve(int t)

{

    char o=S[t];

    while (t<N)

    {

        t++;

        if(S[t]!=o)

        {

            /* cout<<t<<" "<<S[t]<<endl; */

            result+=1;

            return t;

        }

    }  

    return t;

}

int main()

{

    cin>>N;

    cin>>S;

    int len=0;

    while (len<N)

    {

        len=solve(len);

    }

    

    cout<<result<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.236361020795669x):
#include<stdio.h>



int main(){

long n = 0, result=0;

scanf("%d\n", &n);

char s[n];



for(long i = 0; i<n; i++){scanf("%c", &s[i]);}



int temp=0;

for(long i = 0; i<n; ){

    while(1){

    if(s[i]==s[i+1]){

        temp=1;

        i++;

    }else{

        i++;

        break;}

    }

    if(temp){result+=temp;}else{result+=1;}

}

printf("%ld", result);

return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int main()

{

	int n,m=0;

	char a[100009];

	cin>>n;

	cin>>a;

	for(int i=1;i<=n;i++)

	{

		if(a[i]!=a[i-1])

		{

			m++;

		}

	}

	cout<<m<<endl;

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 5.224391238550137x):
#include<stdio.h>



int main(){

long n = 0, result=0;

scanf("%d\n", &n);

char s[n];



for(long i = 0; i<n; i++){scanf("%c", &s[i]);}



int temp=0;

for(long i = 0; i<n; ){

    while(1){

    if(s[i]==s[i+1]){

        temp=1;

        i++;

    }else{

        i++;

        break;}

    }

    if(temp){result+=temp;}else{result+=1;}

}

printf("%ld", result);

return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main()

{

    long int n;

    int i,sum=0,temp;

    string s;

    cin >> n;

    cin >> s;

    temp=s[0];

    for(i=0; i<=n-1; i++)

    {   if(s[i+1]==s[i])

            continue;

        else

        {

            temp=s[i+1];

            sum++;

        }





    }

    cout <<sum;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.266121716947011x):
#include<stdio.h>



int main(){

long n = 0, result=0;

scanf("%d\n", &n);

char s[n];



for(long i = 0; i<n; i++){scanf("%c", &s[i]);}



int temp=0;

for(long i = 0; i<n; ){

    while(1){

    if(s[i]==s[i+1]){

        temp=1;

        i++;

    }else{

        i++;

        break;}

    }

    if(temp){result+=temp;}else{result+=1;}

}

printf("%ld", result);

return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <vector>



using namespace std;

int main()

{

    int n; cin >> n;

    string s; char t;

    cin >> t;

    s.push_back(t);

    for( int i = 1; i < n; ++ i )

    {

        cin >> t;

        if( t == s.back() )

            continue;

        else s.push_back(t);

    }

    cout << s.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.258792593232246x):
#include <stdio.h>

  

int main(){

  int i,n,cnt=1;

  scanf("%d",&n);

  getchar();

    char a[n];

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

  scanf("%c",&a[i]);

  }

  

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

    if(a[i]!=a[i+1])

	cnt++;

  }

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



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

#include<cstring>

using namespace std;

int n;

string str;

int main()

{

	cin >> n;

	cin >> str;

	int ans = 1;

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

	{

		if (i != 0 && str[i] != str[i - 1])

			ans++;

	}

	cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.227048968581219x):
#include <stdio.h>

  

int main(){

  int i,n,cnt=1;

  scanf("%d",&n);

  getchar();

    char a[n];

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

  scanf("%c",&a[i]);

  }

  

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

    if(a[i]!=a[i+1])

	cnt++;

  }

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



  return 0;

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

#define Mod 1000000007

#define eps 1e-6

#define ll long long

#define INF 0x3f3f3f3f

#define MEM(x, y) memset(x, y, sizeof(x))

#define Maxn 1000000 + 10

using namespace std;

int N;

string S;

int result=0;

int solve(int t)

{

    char o=S[t];

    while (t<N)

    {

        t++;

        if(S[t]!=o)

        {

            /* cout<<t<<" "<<S[t]<<endl; */

            result+=1;

            return t;

        }

    }  

    return t;

}

int main()

{

    cin>>N;

    cin>>S;

    int len=0;

    while (len<N)

    {

        len=solve(len);

    }

    

    cout<<result<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.227192544914823x):
#include <stdio.h>

  

int main(){

  int i,n,cnt=1;

  scanf("%d",&n);

  getchar();

    char a[n];

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

  scanf("%c",&a[i]);

  }

  

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

    if(a[i]!=a[i+1])

	cnt++;

  }

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



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int main()

{

	int n,m=0;

	char a[100009];

	cin>>n;

	cin>>a;

	for(int i=1;i<=n;i++)

	{

		if(a[i]!=a[i-1])

		{

			m++;

		}

	}

	cout<<m<<endl;

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 5.215243720861322x):
#include <stdio.h>

  

int main(){

  int i,n,cnt=1;

  scanf("%d",&n);

  getchar();

    char a[n];

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

  scanf("%c",&a[i]);

  }

  

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

    if(a[i]!=a[i+1])

	cnt++;

  }

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



  return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main()

{

    long int n;

    int i,sum=0,temp;

    string s;

    cin >> n;

    cin >> s;

    temp=s[0];

    for(i=0; i<=n-1; i++)

    {   if(s[i+1]==s[i])

            continue;

        else

        {

            temp=s[i+1];

            sum++;

        }





    }

    cout <<sum;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2569011323166395x):
#include <stdio.h>

  

int main(){

  int i,n,cnt=1;

  scanf("%d",&n);

  getchar();

    char a[n];

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

  scanf("%c",&a[i]);

  }

  

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

    if(a[i]!=a[i+1])

	cnt++;

  }

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



  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <vector>



using namespace std;

int main()

{

    int n; cin >> n;

    string s; char t;

    cin >> t;

    s.push_back(t);

    for( int i = 1; i < n; ++ i )

    {

        cin >> t;

        if( t == s.back() )

            continue;

        else s.push_back(t);

    }

    cout << s.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.260861850839864x):
#include <stdio.h>

#include <string.h>

int main ()

{

	long long int N,i,j,l;

	char S[1000000],a[1000000];

	scanf("%lld %s",&N,S);

	a[0]=S[0];

	for(i=1,j=1;S[j]!='\0';j++)

	{

		

		if(a[i-1]==S[j])

		{

			continue;

		}

		else

		{

			a[i]=S[j];

			i++;

		}

		

	}

	l=strlen(a);

	printf("%lld",l);

	

	for(i=0;i<l;i++)

	{

		a[i]='\0';

	}

	return 0;

	

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

#include<cstring>

using namespace std;

int n;

string str;

int main()

{

	cin >> n;

	cin >> str;

	int ans = 1;

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

	{

		if (i != 0 && str[i] != str[i - 1])

			ans++;

	}

	cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.235142030769947x):
#include <stdio.h>

#include <string.h>

int main ()

{

	long long int N,i,j,l;

	char S[1000000],a[1000000];

	scanf("%lld %s",&N,S);

	a[0]=S[0];

	for(i=1,j=1;S[j]!='\0';j++)

	{

		

		if(a[i-1]==S[j])

		{

			continue;

		}

		else

		{

			a[i]=S[j];

			i++;

		}

		

	}

	l=strlen(a);

	printf("%lld",l);

	

	for(i=0;i<l;i++)

	{

		a[i]='\0';

	}

	return 0;

	

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

#define Mod 1000000007

#define eps 1e-6

#define ll long long

#define INF 0x3f3f3f3f

#define MEM(x, y) memset(x, y, sizeof(x))

#define Maxn 1000000 + 10

using namespace std;

int N;

string S;

int result=0;

int solve(int t)

{

    char o=S[t];

    while (t<N)

    {

        t++;

        if(S[t]!=o)

        {

            /* cout<<t<<" "<<S[t]<<endl; */

            result+=1;

            return t;

        }

    }  

    return t;

}

int main()

{

    cin>>N;

    cin>>S;

    int len=0;

    while (len<N)

    {

        len=solve(len);

    }

    

    cout<<result<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 4.235258361450744x):
#include <stdio.h>

#include <string.h>

int main ()

{

	long long int N,i,j,l;

	char S[1000000],a[1000000];

	scanf("%lld %s",&N,S);

	a[0]=S[0];

	for(i=1,j=1;S[j]!='\0';j++)

	{

		

		if(a[i-1]==S[j])

		{

			continue;

		}

		else

		{

			a[i]=S[j];

			i++;

		}

		

	}

	l=strlen(a);

	printf("%lld",l);

	

	for(i=0;i<l;i++)

	{

		a[i]='\0';

	}

	return 0;

	

}