import java.util.Scanner; import java.util.TreeMap; public class Swapstring { public static void main(String[] args) { Scanner s = new Scanner(System.in); StringBuilder S = new StringBuilder(s.nextLine()); s.close(); TreeMap str = new TreeMap<>(); for(int i = 0;i < S.length();i++){ char c = S.charAt(i); if(str.containsKey(c)){ str.put(c, str.get(c)+1); }else{ str.put(c, 1); } } int p = 1; while(str.size() != 0){ char k = str.firstKey(); p *= seki(str.get(k)); str.remove(k); } int all = seki(S.length()); System.out.println(all/p - 1); } static int seki(int k){ int p = 1; for(int i = 1;i <= k;i++){ p *= i; } return p; } }