//
// Noszály Áron 9a Debreceni Fazekas Mihály Gimnázium
// noszalyaron4@gmail.com
//
// g++ 5.4.0 -std=c++14
//
#include<bits/stdc++.h>
#include<cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define INF std::numeric_limits<int>::max()
#define MINF std::numeric_limits<int>::min()
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define xx first
#define yy second
#define sz(x) (int)(x).size()

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

const long double PI = acos(-1);

int d1[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int d2[8][2]={{1,0},{0,1},{0,-1},{-1,0},{1,1},{-1,1},{1,-1},{-1,-1}};

int a[3000001];
int c[3000001];
int g[3000001];
int t[3000001];
int main()
{
	IO;	
	string tt;cin>>tt;
	
	a[sz(tt)-1]=c[sz(tt)-1]=g[sz(tt)-1]=t[sz(tt)-1]=INF;

	if(tt[sz(tt)-1]=='A') a[sz(tt)-1]=sz(tt)-1;
	if(tt[sz(tt)-1]=='C') c[sz(tt)-1]=sz(tt)-1;
	if(tt[sz(tt)-1]=='G') g[sz(tt)-1]=sz(tt)-1;
	if(tt[sz(tt)-1]=='T') t[sz(tt)-1]=sz(tt)-1;
	for(int i=sz(tt)-2;i>=0;i--)
	{
		a[i]=c[i]=g[i]=t[i]=INF;
		if(tt[i]=='A') a[i]=i;
		if(tt[i]=='C') c[i]=i;
		if(tt[i]=='G') g[i]=i;
		if(tt[i]=='T') t[i]=i;
		
		a[i]=min(a[i+1], a[i]);
		c[i]=min(c[i+1], c[i]);
		g[i]=min(g[i+1], g[i]);
		t[i]=min(t[i+1], t[i]);
	}
	
	int ans=0;
	
	for(int i=0;i<(sz(tt)-1);++i)
	{
		if(tt[i]=='A') {
			
			if(tmin(c[i],g[i], t[i])!=INF)
			{
				ans++;
			}
		}else if(tt[i]=='C')
		{
			int val=min(g[i], t[i]);
			if(val!=INF && val<a[i])
			{
				ans++;
			}
		}else if(tt[i]=='G')
		{
			if(t[i]!=INF && t[i]<min(a[i], c[i]))
			{
				ans++;
			}
		}
	
	}
	
	cout<<ans<<"\n";	
}

