import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); char[] input = scanner.next().toCharArray(); scanner.close(); int[] alphabets = new int[26]; for (int i = 0; i < input.length; i++) { alphabets[(int) input[i] - 'A']++; } long ans = 1; PriorityQueue multiply = new PriorityQueue<>(); for (int i = 1; i <= input.length; i++) { multiply.add(i); } PriorityQueue divders = new PriorityQueue<>(); for (int i = 0; i < alphabets.length; i++) { for (int j = 1; j <= alphabets[i]; j++) { divders.add(j); } } while (!multiply.isEmpty() || !divders.isEmpty()) { if (!divders.isEmpty() && ans % divders.peek() == 0) { ans /= divders.poll(); } if (!multiply.isEmpty() && ans < Integer.MAX_VALUE) { ans *= multiply.poll(); } if (ans > Integer.MAX_VALUE) { ans %= 573; } } ans %= 573; if (ans == 0) { ans += 573; } System.out.println(ans - 1); } }