s = gets.chomp min = 101 idx3 = 0 while idx3 break unless idx1 = s.index('c', idx3) break unless idx2 = s.index('w', idx1) break unless idx3 = s.index('w', idx2 + 1) min = [idx3 - idx1 + 1, min].min end puts min == 101 ? -1 : min