#include <bits/stdc++.h>
using namespace std;
char s[10000010];
int r, b, g, w;
int ans;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> s;
int l = strlen(s) - 1;
for(int i = 0; i <= l; i ++)
{
if(s[i] == 'R')
r ++;
else if(s[i] == 'B')
b ++;
else
g ++;
if(r + w == 3 || b + w == 3 || g + w == 3)
{
r = 0;
b = 0;
g = 0;
w = 1;
ans ++;
}
if((r + w >= 1 && b >= 1 && g >= 1) || (r >= 1 && b + w >= 1 && g >= 1) || (r >= 1 && b >= 1 && g + w >= 1))
{
if(i == l)
{
cout << ans;
return 0;
}
w = 0;
r = 0;
b = 0;
g = 0;
ans ++;
i ++;
}
}
cout << ans;
return 0;
}
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_filebuf::underflow error reading the file
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
--------------------------------
Process exited after 2.18 seconds with return value 3
请按任意键继续. . .