S = "ilovechiwawa" def chk_chiwawa(input): count_len = 0 count_cww = 0 cww_num = -1 for i in input: if count_cww == 3: cww_num = count_len break if count_cww >= 1: if i == "w": count_cww += 1 count_len += 1 continue if i == "c": count_cww += 1 count_len += 1 return cww_num if __name__ == '__main__': output = chk_chiwawa(S) print(output, '\n')