# -*- coding: utf-8 -*- s = list(input()) findc = True findFW = False findSW = False first = 0 end = 0 ans = 999999 for i in range(len(s)): if findc: if s[i] == "c": first = i findc = False findFW = True elif findFW: if s[i] == "w": findFW = False findSW = True elif findSW: if s[i] == "w": end = i findSW = False findc = True ans = min(ans,end-first+1) if ans == 999999: ans = -1 print(ans)