stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int a[1010][1010],b[1010][1010];

int s1[1010][1010],s2[1010][1010];

int n,m;

char c[10];

int dfs(int x,int y)

{

    int i=0,j=0;

	i=s1[m][m]-s1[x][m]-s1[m][y]+s1[x][y]+s1[x][y];

	i+=s2[x][m]+s2[m][y]-s2[x][y]-s2[x][y];

	j+=s2[m][m]-s2[x][m]-s2[m][y]+s2[x][y]+s2[x][y];

	j+=s1[x][m]+s1[m][y]-s1[x][y]-s1[x][y];

	return max(i,j);

}

int main()

{

    int i,j,k,x,y,ans;

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

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

    {

        scanf("%d%d%s",&x,&y,c);

        j=x%m;

        k=y%m;

        if(j==0)

            j=m;

        if(k==0)

            k=m;

        if(((abs(x-j)+abs(y-k))/m)%2==1)

        {

            if(c[0]=='W')

                c[0]='B';

            else

                c[0]='W';

        }

        if(c[0]=='W')

            b[j][k]++;

        else

            a[j][k]++;

    }

    for(i=1;i<=m;i++)

    for(j=1;j<=m;j++)

    {

        s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+a[i][j];

        s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+b[i][j];

    }

    ans=0;

    for(i=0;i<=m+1;i++)

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

    ans=max(ans,dfs(i,j));

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

    return 0;

}


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

#include<string.h>

#include<algorithm>

#include<math.h>

using namespace std;

int a[1010][1010],b[1010][1010];

int s1[1010][1010],s2[1010][1010];

int n,m;

char c[10];

int dfs(int x,int y)

{

    int i=0,j=0;

    i=s1[m][m]-s1[x][m]-s1[m][y]+s1[x][y]*2;

    i=i+s2[x][m]+s2[m][y]-s2[x][y]*2;

    j=s2[m][m]-s2[x][m]-s2[m][y]+s2[x][y]*2;

    j=j+s1[x][m]+s1[m][y]-s1[x][y]*2;

    return max(i,j);

}

int main()

{

    int i,j,k,x,y,ans;

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

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

    {

        scanf("%d%d%s",&x,&y,c);

        j=x%m;

        k=y%m;

        if(j==0)

            j=m;

        if(k==0)

            k=m;

        if(((abs(x-j)+abs(y-k))/m)%2==1)

        {

            if(c[0]=='W')

                c[0]='B';

            else

                c[0]='W';

        }

        if(c[0]=='W')

            a[j][k]++;

        else

            b[j][k]++;

    }

    for(i=1;i<=m;i++)

    for(j=1;j<=m;j++)

    {

        s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+a[i][j];

        s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+b[i][j];

    }

    ans=0;

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

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

    ans=max(ans,dfs(i,j));

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

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

#include <algorithm>

#include <cstring>

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

#define MOD 1000000007

#define INF 0x3f3f3f3f

#define INFL 0x3f3f3f3f3f3f3f3f

#define EPS (1e-10)

using namespace std;

typedef long long ll;

typedef pair<int,int>P;



int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];

char s[100000][2];

int cnt[100000];

int n,k;



void add(int x,int t){//(x+??)/k%2=t

	if((x_div_k[x]&1)==0){

		if(t==0){//たさない

			cnt[0]++;

			cnt[k-x_mod_k[x]]--;

		}

		else{//たす

			cnt[k-x_mod_k[x]]++;

		}

	}

	else{

		if(t==0){

			cnt[k-x_mod_k[x]]++;

		}

		else{

			cnt[0]++;

			cnt[k-x_mod_k[x]]--;

		}

	}

}

signed main(){

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

	rep(i,n){

		scanf("%d%d%s",&x[i],&y[i],s[i]);

		x_mod_k[i]=y[i]%k;

		x_div_k[i]=y[i]/k;

	}

	int Max=0;

	rep(i,k){

		memset(cnt,0,sizeof(cnt));

		rep(j,n){

			if(s[j][0]=='B'){

				if(((x[j]+i)/k)%2==0){//(y[j]+t)/K%2=0

					add(j,0);

				}

				else{

					add(j,1);

				}

			}

			else{

				if(((x[j]+i)/k)%2==0){//(y[j]+t)/K%2=1

					add(j,1);

				}

				else{

					add(j,0);

				}

			}

		}

		rep(j,k){

			if(j)cnt[j]+=cnt[j-1];

			Max=max({Max,cnt[j],n-cnt[j]});

		}

	}

	cout<<Max<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 7.6571516476024435x):
extern "C"{

int printf (const char *__restrict __format, ...);

int scanf (const char *__restrict __format, ...) ;

}

int max(int a,int b){

	return a>b?a:b;

}

int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];

char s[100000][2];

int n,k;

 

void add(int*cnt,int x,int t){

	if((x_div_k[x]&1)==0){

		if(t==0){

			cnt[0]++;

			cnt[k-x_mod_k[x]]--;

		}

		else{

			cnt[k-x_mod_k[x]]++;

		}

	}

	else{

		if(t==0){

			cnt[k-x_mod_k[x]]++;

		}

		else{

			cnt[0]++;

			cnt[k-x_mod_k[x]]--;

		}

	}

}

int ans[2000];

int main(){

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

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

		scanf("%d%d%s",&x[i],&y[i],s[i]);

		x_mod_k[i]=y[i]%k;

		x_div_k[i]=y[i]/k;

	}

	int Max=0;

	//~ #pragma omp parallel for num_threads(2)

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

		int d=max(n,k);

		int cnt[d];

		for(int j=0;j<d;j++)cnt[j]=0;

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

			if(s[j][0]=='B'){

				if(((x[j]+i)/k)%2==0){

					add(cnt,j,0);

				}

				else{

					add(cnt,j,1);

				}

			}

			else{

				if(((x[j]+i)/k)%2==0){

					add(cnt,j,1);

				}

				else{

					add(cnt,j,0);

				}

			}

		}

		for(int j=0;j<k;j++){

			if(j)cnt[j]+=cnt[j-1];

			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));

		}

	}

	for(int i=0;i<k;i++)Max=max(Max,ans[i]);

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

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

using namespace std;



int main(){

    int x1,x2,x3,x4,x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    int ans = 0;

    if(x1 == 0){ans = 1;}

    if(x2 == 0){ans = 2;}

    if(x3 == 0){ans = 3;}

    if(x4 == 0){ans = 4;}

    if(x5 == 0){ans = 5;}

    cout << ans << endl;

    return 0;

}


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





int main(){

    int i;

    for(i = 1; i <= 5; i++){

        int x;

        scanf("%d", &x);

            if(x == 0){

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

                return 0;

            }

    }

    return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#include<vector>

#include<queue>

#include<set>

#include<map>

#define ll long long

#define inf 1e9

#define eps 1e-10

#define mod 9901

#define mkp make_pair

using namespace std;

int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx;

int read()

{

	int x=0,f=1;char ch=getchar();

	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}

	while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}

	return x*f;

}

int kabs(int a)

{

   if (a<0) return -a;

   return a; 

}

void add(int &x,int y)

{

   x+=y;

   if (x>=mod) x-=mod;

}

void dec(int &x,int y)

{

	x-=y;

	if (x<0) x+=mod;

}

char ch[101000];

int main()

{

	scanf("%s",ch+1);

	n=strlen(ch+1);

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

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

			s++;

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

}

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

#include <cstring>

const int maxn=1e5+10;

char s[maxn];

int main() {

    while (~scanf("%s",s)) {

        int len=strlen(s);

        int ans=0;

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

            if (s[i]!=s[i+1]) ans++;

        }

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

    }

    return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#include<vector>

#include<queue>

#include<set>

#include<map>

#define ll long long

#define inf 1e9

#define eps 1e-10

#define mod 9901

#define mkp make_pair

using namespace std;

int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx;

int read()

{

	int x=0,f=1;char ch=getchar();

	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}

	while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}

	return x*f;

}

int kabs(int a)

{

   if (a<0) return -a;

   return a; 

}

void add(int &x,int y)

{

   x+=y;

   if (x>=mod) x-=mod;

}

void dec(int &x,int y)

{

	x-=y;

	if (x<0) x+=mod;

}

char ch[101000];

int main()

{

	scanf("%s",ch+1);

	n=strlen(ch+1);

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

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

			s++;

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

}

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

const int MAXN=110000;

char s[MAXN];

int main()

{

//	freopen("C.in", "r", stdin);

//	freopen("C.out", "w", stdout);

	int ans=0;

	scanf("%s", s);

	for (int i=1; s[i]; i++)

		if (s[i]!=s[i-1]) ans++;

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

	return 0;

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

using namespace std;

#define ll long long

#include <string>

#include <algorithm>

int main()

{

	string a;

	cin>>a;

	char c=a[0];

	int count=0;

	for(int i=0;i<a.size();i++)

	{

		if(a[i]!=c)

		{

			c=a[i];

			count++;

		}

	}

	cout<<count<<endl;

	return 0;

} 


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

const int MAXN=110000;

char s[MAXN];

int main()

{

//	freopen("C.in", "r", stdin);

//	freopen("C.out", "w", stdout);

	int ans=0;

	scanf("%s", s);

	for (int i=1; s[i]; i++)

		if (s[i]!=s[i-1]) ans++;

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

	return 0;

}
// Slower C++ solution:
/*g++ file.cpp -o file.out*/

/*./file.out*/



#include <cmath>

#include <cstdio>

#include <string>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



#define LL long long

#define Mod 1000000007

#define L_Mod 17100000013



char str[100001];



int main()

{

    int mn=0;

    cin>>str;

    for(int i=0; i<strlen(str)-1; i++)

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

            mn++;

    cout<<mn;

    return 0;

}


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

const int MAXN=110000;

char s[MAXN];

int main()

{

//	freopen("C.in", "r", stdin);

//	freopen("C.out", "w", stdout);

	int ans=0;

	scanf("%s", s);

	for (int i=1; s[i]; i++)

		if (s[i]!=s[i-1]) ans++;

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

	return 0;

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

using namespace std;

int main()

{

    string s;

    cin>>s;

    int cc=0;

    for(int i=1;i<s.size();i++)

    {

        if(s[i]!=s[i-1]) cc++;

    }

    cout<<cc<<endl;

}


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

const int MAXN=110000;

char s[MAXN];

int main()

{

//	freopen("C.in", "r", stdin);

//	freopen("C.out", "w", stdout);

	int ans=0;

	scanf("%s", s);

	for (int i=1; s[i]; i++)

		if (s[i]!=s[i-1]) ans++;

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

	return 0;

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

const int N = 100010;



char s[N];



int main()

{

    scanf("%s", s);

    int cnt = 0, len = strlen(s);

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

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

            cnt ++;

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

    return 0;

}

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

#include <algorithm>

#include <cmath>

using namespace std;

#include <cstring>

const int MAXN = 100005;

char s[MAXN]; int n;



int main() {

    scanf("%s", s + 1), n = strlen(s + 1);

    int ans = 0;

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

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

            ans++;

    printf("%d", ans - 1);

    return 0;

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

const int N = 100010;



char s[N];



int main()

{

int aa;

    scanf("%s", s);

    int cnt = 0, len = strlen(s);

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

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

            cnt ++;

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

    return 0;

}

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

#include <algorithm>

#include <cmath>

using namespace std;

#include <cstring>

const int MAXN = 100005;

char s[MAXN]; int n;



int main() {

    scanf("%s", s + 1), n = strlen(s + 1);

    int ans = 0;

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

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

            ans++;

    printf("%d", ans - 1);

    return 0;

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

const int MAXN = 100000+10;

typedef long long LL;

char s[MAXN];

int ans;

int main(){

    //freopen("t.in", "r", stdin);

    scanf("%s", s+1);

    int l = strlen(s+1);

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

        if(s[i]!=s[i-1]) ans++;

    }

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

    return 0;

}


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

#include <algorithm>

#include <cmath>

using namespace std;

#include <cstring>

const int MAXN = 100005;

char s[MAXN]; int n;



int main() {

    scanf("%s", s + 1), n = strlen(s + 1);

    int ans = 0;

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

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

            ans++;

    printf("%d", ans - 1);

    return 0;

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

using namespace std;

char s[100005];

int main()

{

	scanf("%s",s);

	int n=strlen(s)-1,cnt=1;

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

	{

		if(s[i]!=s[i+1]) cnt++;

	}

	cout<<cnt-1<<endl;

	return 0;

}

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

#include <algorithm>

#include <cmath>

using namespace std;

#include <cstring>

const int MAXN = 100005;

char s[MAXN]; int n;



int main() {

    scanf("%s", s + 1), n = strlen(s + 1);

    int ans = 0;

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

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

            ans++;

    printf("%d", ans - 1);

    return 0;

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

const int N = 100010;



char s[N];



int main()

{

    scanf("%s", s);

    int cnt = 0, len = strlen(s);

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

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

            cnt ++;

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

    return 0;

}

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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

const int N = 100010;



char s[N];



int main()

{

int aa;

    scanf("%s", s);

    int cnt = 0, len = strlen(s);

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

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

            cnt ++;

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

    return 0;

}

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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

const int MAXN = 100000+10;

typedef long long LL;

char s[MAXN];

int ans;

int main(){

    //freopen("t.in", "r", stdin);

    scanf("%s", s+1);

    int l = strlen(s+1);

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

        if(s[i]!=s[i-1]) ans++;

    }

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

    return 0;

}


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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

using namespace std;

char s[100005];

int main()

{

	scanf("%s",s);

	int n=strlen(s)-1,cnt=1;

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

	{

		if(s[i]!=s[i+1]) cnt++;

	}

	cout<<cnt-1<<endl;

	return 0;

}

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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

const int LEN = 1e5 + 5;

int i, j, k, n, m, s, t, ans, now;

char c[LEN], nowc;

int main() {

    scanf("%s", c + 1);

    n = strlen(c + 1);

    now = 1, nowc = c[1];

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

        if (c[i] != c[i - 1]) {

            ans++;

        }

    }

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

    return 0;

}

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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#include<vector>

#include<queue>

#include<set>

#include<map>

#define ll long long

#define inf 1e9

#define eps 1e-10

#define mod 9901

#define mkp make_pair

using namespace std;

int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx;

int read()

{

	int x=0,f=1;char ch=getchar();

	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}

	while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}

	return x*f;

}

int kabs(int a)

{

   if (a<0) return -a;

   return a; 

}

void add(int &x,int y)

{

   x+=y;

   if (x>=mod) x-=mod;

}

void dec(int &x,int y)

{

	x-=y;

	if (x<0) x+=mod;

}

char ch[101000];

int main()

{

	scanf("%s",ch+1);

	n=strlen(ch+1);

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

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

			s++;

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

}

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

#include<cstring>

char str[100005];

int main()

{

    scanf("%s",str);

    int len=strlen(str);

    int ans=0;

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

    {

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

            ans++;

    }

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

    return 0;

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

using namespace std;

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



int main(void){

	int cnt=0;

	string s;

	cin>>s;

	rep(i,s.size()-1){

		if(s[i]!=s[i+1])cnt++;

	}

	cout<<cnt<<endl;



	return 0;

}


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

int main(){

	int cnt=0;

	char b=getchar(),c;

	while((c=getchar())!='\n'){

		if(b!=c)cnt++;

		b=c;

	}

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

	return 0;

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

int main(void){

	int cnt=0;

	char b=getchar(),c;

	while((c=getchar())!='\n'){

		if(b!=c)cnt++;

		b=c;

	}

	std::cout<<cnt<<std::endl;

	return 0;

}


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

int main(){

	int cnt=0;

	char b=getchar(),c;

	while((c=getchar())!='\n'){

		if(b!=c)cnt++;

		b=c;

	}

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

	return 0;

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

using namespace std;



int main(){

	string s;

	

	cin >> s;

	int i = 0,ans = 0;

	char c = s[0];

	

	while(i<s.size()){

		while(s[i]==c&&i<s.size()) i++;

		ans++;

		c = s[i];

	}

	 cout << ans-1;

}

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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

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

using namespace std;

typedef long long ll;

int  main(){

    string s;

    cin>>s;

    if(s.find('W')==-1||s.find('B')==-1){

        cout<<"0"<<endl;

    }

else{

    int cnt=0;

        for(int i=0; i<s.size()-1; i++){

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

                cnt++;

        }

        cout<<cnt<<endl;

}

return 0;

}


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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

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

#include<cstring>

using namespace std;

int main() {

	int ans = 0;

	string s; 

	cin>>s;

	for(int i=0;i<s.length()-1;i++) {

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

			ans++;

	}

	cout<<ans<<endl;

	return 0;

}

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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

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

#include<algorithm>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cstdio>

#include<string>

//#include<string>

//#include<sstream>

using namespace std;



int main()

{

	int n,i,l;

	char a[100005];

	scanf("%s",&a);

	l=strlen(a);

	n=1;

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

	{

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

			n++;

	}

	printf("%d\n",n-1);

}

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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

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

#include <math.h>

#include <string.h>

#include <algorithm>

#include <iostream>

#include <string>

#include <time.h>

#include <queue>

#include <list>

#include <string.h>

#define sf scanf

#define pf printf

#define lf double

#define ll long long

#define p123 printf("123\n");

#define pn printf("\n");

#define pk printf(" ");

#define p(n) printf("%d",n);

#define pln(n) printf("%d\n",n);

#define s(n) scanf("%d",&n);

#define ss(n) scanf("%s",n);

#define ps(n) printf("%s",n);

#define sld(n) scanf("%lld",&n);

#define pld(n) printf("%lld",n);

#define slf(n) scanf("%lf",&n);

#define plf(n) printf("%lf",n);

#define sc(n) scanf("%c",&n);

#define pc(n) printf("%c",n);

#define gc getchar();

#define re(n,a) memset(n,a,sizeof(n));

#define len(a) strlen(a)

#define LL long long

#define eps 1e-6

using namespace std;

const double pi = 3.1415926535;

/*

https://codeforces.com/contest/1106/problems

https://codeforces.com/contest/1106/submit

*/



int main(){

	/*ll n,x;

	ll a[1000000];

    sld(n) sld(x)

    ll sum = 0;

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



    }*/



    char a[1000000];

    ss(a)

    int lena = len(a);

    int sum = 0;

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

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

            sum ++;

        }

    }

    p(sum) pn

    return 0;



}




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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

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

using namespace std;

#define ll long long



char s[100005];

int main()

{

    int b,w;

	while(cin >> s)

	{

	    b = 0,w = 0;

	    int len = strlen(s);

	    bool bf = 0,wf = 0;

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

	    {

	        if(s[i] == 'B' && bf == 0)

	        {

	            b++;

	            bf = 1,wf = 0;

	        }

	        if(s[i] == 'W' && wf == 0)

	        {

	            w++;

	            wf = 1,bf = 0;

	        }

	    }

	    cout << b + w - 1<< endl;

	}

	return 0;

}


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

#include <cstdio>



using namespace std;



char s[100005],pre;

int cnt;



int main()

{

    scanf("%s",s); 

	pre=s[0];

    for(int i=1;i<strlen(s);i++)

      	if(pre!=s[i]) cnt++,pre=s[i];

    printf("%d",cnt);

    return 0;

}