S = input() cww_col = ["c", "w", "w"] check = [] # check == [[:now, :len], ... ,[]] for Si in S: if Si == cww_col[0]: check.append([0, 0]) for c in check: if c[0] < 2: if Si == cww_col[1]: c[0] += 1 c[1] += 1 check = sorted([c for c in check if c[0] == 2], key=lambda x:x[1]) if len(check) == 0: print(-1) else: print(check[0][1])