// Arup Guha
// 2/16/2017
// Solution to 2017 February USACO Bronze Problem: Why Did the Cow Cross the Road II?

import java.util.*;
import java.io.*;

public class circlecross {

	public static void main(String[] args) throws Exception {

		// Read input.
		Scanner stdin = new Scanner(new File("circlecross.in"));
		String s = stdin.next();

		// Mark which ones we've processed in seen and which ones have crossed in crossed with i < j for cross[i][j].
		boolean[] seen = new boolean[26];
		boolean[][] cross = new boolean[26][26];

		// Go through the string.
		for (int i=0; i<s.length(); i++) {

			// Processed this one already.
			if (seen[s.charAt(i)-'A']) continue;

			// Mark it.
			seen[s.charAt(i)-'A'] = true;

			// See which characters appear exactly once between the two occurrences of this char.
			int[] freq = new int[26];
			int j = i+1;
			while (s.charAt(j) != s.charAt(i)) {
				freq[s.charAt(j)-'A']++;
				j++;
			}

			// These are the pairs we want to mark.
			for (int k=0; k<26; k++) {
				if (freq[k] == 1) {
					int id = s.charAt(i)-'A';
					cross[Math.min(k,id)][Math.max(k,id)] = true;
				}
			}
		}

		// Add up our answer.
		int res = 0;
		for (int i=0; i<26; i++)
			for (int j=i+1; j<26; j++)
				if (cross[i][j])
					res++;

		// Output the result.
		PrintWriter out = new PrintWriter(new FileWriter("circlecross.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}