def main(): s = list(input()) cww_count = 0 cww_length = [] for i in range(len(s)): if s[i] == "c": cww_count += 1 right = i elif s[i] == "w" and cww_count == 1: cww_count += 1 elif s[i] == "w" and cww_count == 2: cww_count += 1 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])) # デバッグ用 # print(s) # print(cww_length) if __name__ == "__main__": main()