MOD = 573 s = gets.chomp n = s.size dp = Array.new(n + 1) dp[0] = 1 h = Hash.new(0) 1.upto(n){|i| dp[i] = i * dp[i - 1] h[s[i - 1]] += 1 } p (dp[n] / h.values.map{|x|dp[x]}.inject(:*) - 1) % MOD