S = str(input()) def has_filled_c(chiwawa_index_dict): if chiwawa_index_dict["c"] != 0: return True def has_filled_first_w(chiwawa_index_dict): if chiwawa_index_dict["first_w"] != 0: return True def has_filled_second_w(chiwawa_index_dict): if chiwawa_index_dict["second_w"] != 0: return True chiwawa_index_dict = {"c": 0, "first_w": 0, "second_w": 0} for i, word in enumerate(S): if word == "c" and not has_filled_c(chiwawa_index_dict): chiwawa_index_dict["c"] = i elif word == "w" and has_filled_c(chiwawa_index_dict) and not has_filled_first_w(chiwawa_index_dict): chiwawa_index_dict["first_w"] = i elif word == "w" and has_filled_c(chiwawa_index_dict) and has_filled_first_w(chiwawa_index_dict) and not has_filled_second_w(chiwawa_index_dict): chiwawa_index_dict["first_w"] = i break if has_filled_second_w(chiwawa_index_dict): print(-1) else: print(chiwawa_index_dict["second_w"] - chiwawa_index_dict["c"])