import java.util.ArrayDeque; import java.util.Deque; 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; Deque multiply = new ArrayDeque(); for (int i = 1; i <= input.length; i++) { multiply.add(i); } Deque divders = new ArrayDeque(); for (int i = 0; i < alphabets.length; i++) { for (int j = 1; j <= alphabets[i]; j++) { divders.add(j); } } while (!multiply.isEmpty() || !divders.isEmpty()) { for (int i = 0; i < divders.size(); i++) { int poll = divders.pollFirst(); System.out.println(poll); if (ans % poll == 0) { ans /= poll; } else { divders.addLast(poll); } if (ans == 1) { break; } } for (int i = 0; i < multiply.size(); i++) { if (ans > Integer.MAX_VALUE) { if (divders.size() > 0) { break; } else { ans %= 573; } } ans *= multiply.poll(); } } ans %= 573; if (ans == 0) { ans += 573; } System.out.println(ans - 1); } }