def min(a,b); a < b ? a : b; end S = gets.chomp ans = S.size * 2 W = S.size.times.select{|i| S[i] == 'w' }.each_cons(2).to_a C = S.size.times.select{|i| S[i] == 'c' } C.each do |i| w = W.find{|w_| i < w_[0] } ans = min(ans, w[1] - i + 1) if w end puts ans <= S.size ? ans : -1