import
java.util.*;
class
GFG{
public
static
int
findMinLength(String s)
{
int
n = s.length();
HashMap<Character,
Integer> counts =
new
HashMap<>();
Vector<Integer> indices =
new
Vector<Integer>();
for
(
int
i =
0
; i < n; i++)
{
if
(s.charAt(i) ==
'a'
||
s.charAt(i) ==
'e'
||
s.charAt(i) ==
'o'
||
s.charAt(i) ==
'i'
||
s.charAt(i) ==
'u'
)
{
if
(counts.containsKey(s.charAt(i)))
{
counts.replace(s.charAt(i),
counts.get(s.charAt(i)) +
1
);
}
else
{
counts.put(s.charAt(i),
1
);
}
indices.add(i);
}
}
if
(counts.size() <
5
)
return
-
1
;
int
flag1 =
0
, flag2 =
0
;
int
i =
0
;
int
j = indices.size() -
1
;
while
((j - i) >=
4
)
{
if
(flag1 ==
0
&&
counts.get(s.charAt(
indices.get(i))) >
1
)
{
counts.replace(s.charAt(indices.get(i)),
counts.get(s.charAt(indices.get(i))) -
1
);
i++;
}
else
flag1 =
1
;
if
(flag2 ==
0
&&
counts.get(s.charAt(
indices.get(j))) >
1
)
{
counts.replace(s.charAt(indices.get(j)),
counts.get(s.charAt(indices.get(j))) -
1
);
j--;
}
else
flag2 =
1
;
if
(flag1 ==
1
&& flag2 ==
1
)
break
;
}
return
(indices.get(j) - indices.get(i) +
1
);
}
public
static
void
main(String[] args)
{
String s =
"aaeebbeaccaaoiuooooooooiuu"
;
System.out.print(findMinLength(s));
}
}