with open('24.txt') as f:
s = f.readline().strip()
order = "VWXYZ"
max_len = 0
i = 0
while i < len(s):
j = i
length = 0
full_groups = 0
# определяем стартовую позицию в шаблоне
if s[j] in order:
pos = order.index(s[j])
else:
i += 1
continue
while j < len(s) and s[j] in order:
if s[j] == order[pos]:
length += 1
pos += 1
if pos == 5:
pos = 0
full_groups += 1
else:
break
j += 1
if full_groups > 0:
max_len = max(max_len, length)
i += 1
print(max_len)