def main(): S = list(input()) cww_lengthes = [] cww_store = [] for i in range(len(S)): if S[i] == 'c': if len(cww_store) == 1: cww_store[0] = i if len(cww_store) == 0: cww_store.append(i) if S[i] == 'w': if len(cww_store) == 2: cww_lengthes.append(i - cww_store[0] + 1) cww_store = [] if len(cww_store) == 1: cww_store.append(i) print(min(cww_lengthes) if cww_lengthes else -1) if __name__ == '__main__': main()