using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var s = ReadLine(); var total = new int[26]; foreach (var c in s) ++total[c - 'A']; var sum = new int[26]; var ans = 0L; for (var i = 0; i < s.Length; ++i) { var c = s[i] - 'A'; ++sum[c]; if (sum[c] > 1) { ans += (long)(sum[c] - 1) * (s.Length - i - 1 - total[c] + sum[c]); } } WriteLine(ans); } }