def main(): S = list(input()) cww_lengthes = [] cww_store = [] for i in range(len(S) - 1): if S[i] == 'c': cww_store.append(i) for j in range(i + 1, len(S)): if S[j] == 'w': if len(cww_store) == 2: cww_lengthes.append(j - 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()