import java.util.ArrayList; 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']++; } ArrayList multiply = new ArrayList(); for (int i = 1; i <= input.length; i++) { multiply.add(i); } int[] m = new int[multiply.size()]; for (int i = 0; i < multiply.size(); i++) { m[i] = multiply.get(i); } ArrayList divders = new ArrayList(); for (int i = 0; i < alphabets.length; i++) { for (int j = 1; j <= alphabets[i]; j++) { divders.add(j); } } int[] d = new int[divders.size()]; for (int i = 0; i < divders.size(); i++) { d[i] = divders.get(i); } for (int i = 0; i < d.length; i++) { for (int j = 0; j < m.length; j++) { long gcd = gcd(d[i], m[j]); d[i] /= (int) gcd; m[j] /= (int) gcd; } } long ans = 1; for (int i = 0; i < m.length; i++) { // System.out.println(mIntegers[i]); ans *= m[i]; ans %= 573; } if (ans == 0) { ans += 573; } System.out.println(ans - 1); } static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } }