// Arup Guha
// 10/5/2019
// Solution to 2019 NAQ Problem K: Summer Trip
// https://open.kattis.com/problems/summertrip
// Note: Written in contest, commented afterwards. I worked with
//       Travis to solve this and then coded it up.

import java.util.*;

public class summertrip {
	
	public static void main(String[] args) {
	
		// Just store indexes of where each letter occurs.
		Scanner stdin = new Scanner(System.in);
		char[] str = stdin.next().toCharArray();
		TreeSet[] trees = new TreeSet[26];
		for (int i=0; i<26; i++)
			trees[i] = new TreeSet<Integer>();
		for (int i=0; i<str.length; i++) 
			trees[str[i]-'a'].add(i);
		
		int res = 0;
		
		// Index i is the first event.
		for (int i=0; i<str.length; i++) {
			
			// See which of the last letters can be an ending event.
			for (int let=0; let<26; let++) {
				int sLet = str[i] - 'a';
				
				// Prohibited.
				if (let == (sLet)) continue;
				
				// Find the first item of this letter that's afterwards
				// my start point.
				Integer end = (Integer)trees[let].higher(i);
				
				// And where I could start with this letter next.
				Integer nextStart = (Integer)trees[sLet].higher(i);
				
				// Not possible with this letter and starting position.
				if (end == null) continue;
				
				// Not possible if starting event occurs before this one.
				if (nextStart != null && nextStart < end) continue;
				
				// If we get here, we found one more streak of events
				// that works.
				res++;
			}
		}
		
		// Ta da!
		System.out.println(res);
	}
}