start = 0 result = 100 input_str = raw_input('') def search_cww(string, start): cww_str = "cww" cww_cnt = 0 str_cnt = 0 for i in range(start, len(string)): if string[i] == cww_str[cww_cnt]: if cww_cnt == 0: c_position = i str_cnt += 1 # print("cww_cnt", cww_cnt) # print("str_cnt", str_cnt) if cww_cnt >= 2: return c_position, str_cnt cww_cnt += 1 else: if cww_cnt > 0: str_cnt += 1 return -1, -1 while True: start, cnt = search_cww(input_str, start) # print("start:", start) # print("cnt:", cnt) start += 1 if cnt < 0: break else: if result > cnt: result = cnt print(result)