#include"bits/stdc++.h" using namespace std; int main() { string s; cin >> s; int ans = s.length() + 1; int a = s.length(); for (int i = 0; i < a- 2; i++) { if (s[i] == 'c') { for (int j = i+1; j < a-1; j++) { if (s[j] == 'w') { for (int k = j + 1; k < s.length(); k++) { if (s[k] == 'w') { ans = min(ans, k-i+1); break; } } break; } } } } if (ans == s.length() + 1) { cout << -1 << endl; } else { cout << ans << endl; } }