def main(): s = list(input()) cww_count = 0 cww_length = [] right_potential = [] for i in range(len(s)): if s[i] == "c": right_potential.append(i) elif s[i] == "w" and cww_count == 0: middle = i cww_count += 1 elif s[i] == "w" and cww_count == 1: left = i if right_potential[0] < middle and right_potential[0] != []: right = max([x for x in right_potential if x < middle]) cww_length.append(left - right + 1) cww_count = 0 if cww_length == []: print(-1) else: sorted_length = sorted(cww_length) print(int(sorted_length[0])) if __name__ == "__main__": main()