def main(): text = input() cww_length = [] cww_store = [] for i in range(len(text)): if text[i] == 'c': cww_store.append(i) for j in range(i, len(text)): if text[j] == 'w': w1 = j for k in range(j + 1, len(text)): if text[k] == 'w': cww_store.append(k) if len(cww_store) == 2: cww_length.append(k - i + 1) cww_store = [] else: cww_store = [] print(min(cww_length) if cww_length else -1) if __name__ == '__main__': main()