import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextInt();
        String s = in.next();
        System.out.println(getCount(s));
    }

    private static long getCount(String s) {
        long count = 0;
        HashMap<Character, Long> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            map.put(s.charAt(i), map.getOrDefault(s.charAt(i), 0L) + 1);
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            Iterator<Map.Entry<Character, Long>> iterator = map.entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry<Character, Long> next = iterator.next();
                char key = next.getKey();
                long value = next.getValue();
                if (key != ch && value >= 2) {
                    count += (value*(value-1)/2);
                }
            }
            map.put(ch, map.get(ch) - 1);
        }
        return count;
    }
}