ss = input() str_count = 0 str_count_start = False w_count = 0 for s in ss: if w_count == 2: break elif s == "c": str_count_start = True elif str_count_start and s == "w": w_count += 1 if str_count_start: str_count += 1 if w_count != 2: print(-1) else: print(str_count)