using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YukiCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int nL = S.Count();
            var la = new List<int>();

            for (int i = 0; i < nL-2; i++)
            {
                int nr = 0;
                if (S[i] != 'c') continue;
                for (int j = i+1; j < nL-1; j++)
                {
                    if (S[j] != 'w') continue;
                    for (int k = j+1; k < nL; k++)
                    {
                        if (S[k] != 'w') continue;
                        nr = k - i + 1;
                        break;
                    }
                    break;
                }
                if (nr > 0) la.Add(nr);
            }
            Console.WriteLine(la.Count() > 0 ? la.Min() : -1);
            Console.ReadLine();
        }
    }
}