// Arup Guha
// 2/24/2024
// Solution to SER D1/D2 Problem A: ABC String

import java.util.*;

public class a {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		char[] s = stdin.next().toCharArray();
		
		// Stores how many streaks have this state.
		// mask of 1 is a, mask of 2 is b, mask of 4 is c...
		int[] mask = new int[7];
		
		// Loop through the string.
		for (int i=0; i<s.length; i++) {
			boolean done = false;
			int val = 1 << (s[i] - 'A');
			
			// Order I want to go through the subsets.
			int[] order = {6,5,3,4,2,1,0};
			
			// Loop through the subsets.
			for (int x=0; x<order.length; x++) {
				int j = order[x];
				
				// This means I have an active set and my letter isn't in it yet.
				if (mask[j] > 0 && (j & (val)) == 0) {
					
					// Add the letter changing the set.
					mask[j]--;
					int newm = j|val;
					
					// If it's full (abc), we return to nothing.
					if (newm == 7) newm = 0;
					
					// Add what this mask has become.
					mask[newm]++;
					
					// We found a string to add this letter.
					done = true;
					break;
				}
			}
			
			// We have to start a new string...
			if (!done) {
				mask[val]++;
			}
		}
		
		// Everything we want will be in index 0 (completed strings).
		System.out.println(mask[0]);
	}
}