//
// 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";
}
Ly8KLy8gTm9zesOhbHkgw4Fyb24gOWEgRGVicmVjZW5pIEZhemVrYXMgTWlow6FseSBHaW1uw6F6aXVtCi8vIG5vc3phbHlhcm9uNEBnbWFpbC5jb20KLy8KLy8gZysrIDUuNC4wIC1zdGQ9YysrMTQKLy8KI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8Y3N0ZGxpYj4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiB1bnNpZ25lZCBsb25nIGxvbmcgdWw7CnR5cGVkZWYgbG9uZyBkb3VibGUgbGQ7CgojZGVmaW5lIGFsbChzKSAocykuYmVnaW4oKSwocykuZW5kKCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBJTyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZSgwKTsgY291dC50aWUoMCkKI2RlZmluZSBJTkYgc3RkOjpudW1lcmljX2xpbWl0czxpbnQ+OjptYXgoKQojZGVmaW5lIE1JTkYgc3RkOjpudW1lcmljX2xpbWl0czxpbnQ+OjptaW4oKQojZGVmaW5lIHRtYXgoYSxiLGMpIG1heCgoYSksbWF4KChiKSwoYykpKQojZGVmaW5lIHRtaW4oYSxiLGMpIG1pbigoYSksbWluKChiKSwoYykpKQojZGVmaW5lIHZwaWkgdmVjdG9yPHBhaXI8aW50LGludD4+CiNkZWZpbmUgdnBsbCB2ZWN0b3I8cGFpcjxsbCxsbD4+CiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgeHggZmlyc3QKI2RlZmluZSB5eSBzZWNvbmQKI2RlZmluZSBzeih4KSAoaW50KSh4KS5zaXplKCkKCiNpZm5kZWYgT05MSU5FX0pVREdFCiMgIGRlZmluZSBMT0coeCkgKGNlcnIgPDwgI3ggPDwgIiA9ICIgPDwgKHgpIDw8IGVuZGwpCiNlbHNlCiMgIGRlZmluZSBMT0coeCkgKCh2b2lkKTApCiNlbmRpZgoKY29uc3QgbG9uZyBkb3VibGUgUEkgPSBhY29zKC0xKTsKCmludCBkMVs0XVsyXT17ezAsMX0sezEsMH0sezAsLTF9LHstMSwwfX07CmludCBkMls4XVsyXT17ezEsMH0sezAsMX0sezAsLTF9LHstMSwwfSx7MSwxfSx7LTEsMX0sezEsLTF9LHstMSwtMX19OwoKaW50IGFbMzAwMDAwMV07CmludCBjWzMwMDAwMDFdOwppbnQgZ1szMDAwMDAxXTsKaW50IHRbMzAwMDAwMV07CmludCBtYWluKCkKewoJSU87CQoJc3RyaW5nIHR0O2Npbj4+dHQ7CgkKCWFbc3oodHQpLTFdPWNbc3oodHQpLTFdPWdbc3oodHQpLTFdPXRbc3oodHQpLTFdPUlORjsKCglpZih0dFtzeih0dCktMV09PSdBJykgYVtzeih0dCktMV09c3oodHQpLTE7CglpZih0dFtzeih0dCktMV09PSdDJykgY1tzeih0dCktMV09c3oodHQpLTE7CglpZih0dFtzeih0dCktMV09PSdHJykgZ1tzeih0dCktMV09c3oodHQpLTE7CglpZih0dFtzeih0dCktMV09PSdUJykgdFtzeih0dCktMV09c3oodHQpLTE7Cglmb3IoaW50IGk9c3oodHQpLTI7aT49MDtpLS0pCgl7CgkJYVtpXT1jW2ldPWdbaV09dFtpXT1JTkY7CgkJaWYodHRbaV09PSdBJykgYVtpXT1pOwoJCWlmKHR0W2ldPT0nQycpIGNbaV09aTsKCQlpZih0dFtpXT09J0cnKSBnW2ldPWk7CgkJaWYodHRbaV09PSdUJykgdFtpXT1pOwoJCQoJCWFbaV09bWluKGFbaSsxXSwgYVtpXSk7CgkJY1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