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