def fact(n); (1 .. n).inject(&:*); end S = gets.chomp C = Hash.new(0) S.chars {|c| C[c] += 1 } A = C.inject(fact(S.size)){|s,(k,c)| s / fact(c) } puts A - 1