package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, _ := strconv.Atoi(sc.Text()) return i } func nextStr() string { sc.Scan() return sc.Text() } func get(n int) []string { inputs := make([]string, n) for index := range inputs { inputs[index] = nextStr() } return inputs } func main() { sc.Split(bufio.ScanWords) str := nextStr() chiwawa := -1 cc := make(map[int]int) wc := make(map[int]int) ccount, wcount := 0, 0 for i, c := range str { if c == 'c' { cc[ccount] = i ccount++ } else if c == 'w' { wc[wcount] = i wcount++ } } if len(wc) < 2 { fmt.Println(chiwawa) } for i := len(wc) - 2; i > -1; i-- { for _, index := range cc { if index-wc[i+1] < chiwawa || chiwawa == -1 { chiwawa = wc[i+1] - index + 1 } if index > wc[i] { break } } } fmt.Println(chiwawa) }