#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include using namespace std; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i ostream & operator<<(ostream & os, vector const &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple const &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple const & t){ os << (n==0?"":" ") << get(t); _ot(os, t); } template ostream & operator<<(ostream & os, tuple const & t){ _ot<0>(os, t); return os; } template ostream & operator<<(ostream & os, pair const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream & operator<<(ostream & os, vector const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<> G >> C >> P){ dump(G,C,P); string s; cin >> s; int g = 0, c = 0, p = 0; for(char e : s){ if(e=='G') g++; if(e=='C') c++; if(e=='P') p++; } int win = 0; int a = min(G,c); win += a; G -= a; c -= a; a = min(C,p); win += a; C -= a; p -= a; a = min(P,g); win += a; P -= a; g -= a; int drow = 0; drow += min(c,C); drow += min(p,P); drow += min(g,G); cout << drow + win*3 << endl; } }