class Yukicoder def initialize s = gets.chomp.chars hash = Hash.new(0) s.each do |ch| hash[ch] += 1 end puts [*(1..s.size)].inject(:*) / hash.values.map{|i| [*(1..i)].inject(:*)}.inject(:*) - 1 end end Yukicoder.new