// Arup Guha
// 3/4/2019
// Solution to 2019 Mercer Problem: Counting the delta permutations of a string

// Note: The bounds were poorly specified in this problem. A limit on the input
//       string length should have been given. This code should work for strings
//       of length upto 20 where the final result is <= 200,000,000.

import java.util.*;

public class delta {

	public static int n;
	public static String s;
	public static int[] memo;
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		// Process each case.
		while (stdin.hasNext()) {
			s = stdin.next();
			n = s.length();
			memo = new int[1<<n];
			Arrays.fill(memo, -1);
			System.out.println(f(0));
		}
	}
	
	public static int f(int mask) {
		
		// Done or done it before.
		if (mask == (1<<n)-1) return 1;
		if (memo[mask] != -1) return memo[mask];
		
		// Slot we are filling in.
		int k = Integer.bitCount(mask);
		
		int res = 0;
		
		boolean[] letterUsed = new boolean[26];
		
		// i is the letter we are trying in location k.
		for (int i=0; i<n; i++) {
		
			// Used already.
			if ((mask & (1<<i)) != 0) continue;
			
			// Derangement property.
			if (s.charAt(i) == s.charAt(k)) continue;
			
			// Don't want to sub the same letter into this place twice.
			if (letterUsed[s.charAt(i)-'a']) continue;
			
			// Add in the contribution of this permutation placing letter i in slot k.
			letterUsed[s.charAt(i)-'a'] = true;
			res += f(mask|(1<<i));
		}
		
		// Store and return.
		return memo[mask] = res;
	}
}
