MOD = 573 def calc_combination(n) res = Array.new(n + 1) { Array.new(n + 1, 1) } 2.upto(n) do |i| 1.upto(i - 1) do |j| res[i][j] = res[i-1][j-1] + res[i-1][j] % MOD res[j][i] = res[i][j] end end res end s = read_line comb = calc_combination(s.size) cnt = Array.new(26, 0) s.each_char do |c| cnt[c - 'A'] += 1 end m = s.size ans = 1 cnt.each do |i| ans = ans * comb[m][i] % MOD m -= i end puts ans - 1