using System; public class Hello { static void Main() { var s = Console.ReadLine().Trim(); getAns(s); } static void getAns(string s) { var n = s.Length; var a = new int[26, n]; for (int i = 0; i < 26; i++) { if (s[0] - 'A' == i) a[i, 0] = 1; for (int j = 1; j < n; j++) { a[i, j] = a[i, j - 1]; if (s[j] - 'A' == i) a[i, j]++; } } var ans = 0L; for (int i = 1; i < n - 1; i++) { var t = s[i] - 'A'; if (a[t, i - 1] < 1) continue; var ww = n - 1 - i - (a[t, n - 1] - a[t, i]); ans += ww * (a[t, i - 1]); } Console.WriteLine(ans); } }