def main(): s = list(input()) cww_count = 0 cww_length = [] for i in range(len(s)): if s[i] == "c" and cww_count == 0: cww_count += 1 right = i elif s[i] == "c" and cww_count == 1: right = i elif s[i] == "w" and cww_count == 1: cww_count += 1 elif s[i] == "w" and cww_count == 2: left = i 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()