def main(): str_count = 0 s = str(input()) # print(s) first_c = s.split("c", 1) # 最初に"c"が出てきた時に、それ以降の文字のカウントをしたい。 # print(first_c) if len(first_c) == 1: print(-1) else: first_w = first_c[1].split("w", 1) str_count += len(first_w[0]) + 1 # print(first_w) if len(first_w) == 1: print(-1) else: second_w = first_w[1].split("w", 1) # print(second_w) str_count += len(second_w[0]) + 2 if len(second_w) == 1: print(-1) else: print(str_count) if __name__ == '__main__': main()