Length of the longest substring consisting only of vowels in non-increasing order

import java.io.*;import java.util.*;  class GFG {                  static int count(String S, int N)    {                  char ch[] = { ‘u’, ‘o’, ‘i’, ‘e’, ‘a’ };                  int j = 0;                  int res = 0;                          int count = 0;                  HashSet mp = new HashSet();                  for (int i = 0; i < N; ++i) {                          if (S.charAt(i) == ch[j]) {                                  ++count;                                  mp.add(S.charAt(i));                                  if (mp.size() == 5) {                    res = Math.max(res, count);                }            }                                      else if (j + 1 < 5                     && S.charAt(i) == ch[j + 1]) {                                  mp.add(S.charAt(i));                                  ++count;                                  j++;                                  if (mp.size() == 5) {                    res = Math.max(res, count);                }            }            else {                                  mp.clear();                                  if (S.charAt(i) == 'u') {                                          mp.add('u');                                          j = 0;                    count = 1;                }                                  else {                    j = 0;                    count = 0;                }            }        }                  return res;    }          public static void main(String[] args)    {                  String S = "ueiaoaeiouuoiea";        int N = S.length();                  System.out.println(count(S, N));    }}