def Perm(n, m) q = 1 m.times do q *= n n -= 1 end return q end def Fact(n) q = 1 n.times do |i| q *= i + 1 end return q end s = gets.strip n = s.length a = Hash.new(0) s.each_char do |x| a[x] += 1 end up = 1 under = 1 a.each_value do |x| up *= Perm(n, x) under *= Fact(x) n -= x end puts up / under - 1