s = input().strip() t = s.count("T") c = s.count("C") g = s.count("G") print(t**2 + c**2 + g**2 + (min((t, c, g)) * 7))