#include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); char c; std::map pos; int minLen = 255; for (int i = 0; std::cin >> c; ++i) { switch (c) { case 'c': case 'w': pos.insert(std::make_pair(i, c)); break; } } for (std::map::iterator it = pos.begin(); it != pos.end(); ++it) { FIND_C: if (it->second == 'c') { for (std::map::iterator it2 = it; it2 != pos.end(); ) { ++it2; if (it2->second == 'w') { for (std::map::iterator it3 = it2; it3 != pos.end(); ) { ++it3; if (it3->second == 'w') { minLen = (minLen > it3->first - it->first + 1) ? it3->first - it->first + 1 : minLen; ++it; goto FIND_C; } } } } } } std::cout << ((minLen == 255) ? -1 : minLen) << "\n"; return 0; }