def main(): s = input() length_minimom = float('inf') for c in range(len(s)): if s[c] == 'c': count_cww = 0 for w in range(c+1, len(s)): if s[w] == 'w': count_cww += 1 if count_cww == 2: length_minimom = min(length_minimom, w - c + 1) break if length_minimom == float('inf'): print(-1) else: print(length_minimom) if __name__ == '__main__': main()