// Arup Guha
// 6/13/2024
// Solution to Kattis Problem: Seven Wonders
// https://open.kattis.com/problems/sevenwonders

using namespace std;
#include <bits/stdc++.h>

int main() {

    string s;
    cin >> s;

    // Count the letters.
    int tCnt = 0, cCnt = 0, gCnt = 0;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == 'T') tCnt++;
        if (s[i] == 'C') cCnt++;
        if (s[i] == 'G') gCnt++;
    }

    // Just follows the rules.
    int res = tCnt*tCnt + cCnt*cCnt + gCnt*gCnt + 7*min(min(tCnt,cCnt), gCnt);
    cout << res << endl;
    return 0;
}
