using System.Collections.Generic; using System; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); var sL = s.Length; if (sL == 1) { Console.WriteLine(0); goto end; } if (sL == 2) if (s[0] == s[1]) { Console.WriteLine(0); goto end; } else { Console.WriteLine(1); goto end; } Console.WriteLine(getAns(s)); end:; } public static int getAns(string s) { var d = new Dictionary(); foreach (var x in s) if (d.ContainsKey(x)) d[x]++; else d[x] = 1; var ans = getFact(s.Length); foreach (var x in d) if (x.Value >= 2) ans /= getFact(x.Value); return ans - 1; } public static int getFact(int n) { if (n == 1) return 1; if (n == 2) return 2; if (n == 3) return 6; var ans = 6; for (int i = 4; i <= n; i++) ans *= i; return ans; } }