def main(): input_string = input() first_c = None first_w = None second_w = None for i, s in enumerate(input_string): if s == "c" and first_c is None: first_c = i if s == "w" and first_w is None and first_c is not None: first_w = i if s == "w" and second_w is None and first_c is not None and first_w is not None and first_w != i: second_w = i if any([first_c is None, first_w is None, second_w is None]): print(-1) else: print(second_w - first_c + 1) if __name__ == "__main__": main()