package main import ( "bufio" "os" "strconv" "strings" "fmt" ) var s = bufio.NewScanner(os.Stdin) func next() string { s.Split(bufio.ScanWords) s.Scan() return s.Text() } func nextLine() string { s.Split(bufio.ScanLines) s.Scan() if nil != s.Err() { panic(s.Err()) } return s.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } func nextLong() int64 { i, e := strconv.ParseInt(next(), 10, 64) if e != nil { panic(e) } return i } //パスカルの三角形でコンビネーション計算 func nCr(n int) [][]int { var dp = make([][]int, n+10) dp[0] = make([]int, n+10) dp[0][0] = 1 for i := 1; i <= n; i++ { dp[i] = make([]int, n+10) dp[i][0] = dp[i-1][0] for j := i; j > 0; j-- { dp[i][j] = dp[i-1][j]+dp[i-1][j-1] dp[i][j]%=573 } } return dp } func mapToString(arr []int) []string { ret := make([]string, len(arr)) for i := 0; i < len(arr); i++ { ret[i] = strconv.Itoa(arr[i]) } return ret } func PrintI(args ...int) { fmt.Println(strings.Join(mapToString(args), " ")) } func main() { S := nextLine() var set = map[rune]int{} for _, s := range S { set[s]+=1 } var leng = len(S) dp := nCr(len(S)) sum := 1 for _, v := range set { sum*=dp[leng][v] leng-=v sum%=573 if sum == 0 { sum = 573 } } PrintI(sum-1) }