NewThe Learning module is now liveSee what's new

You are given a string s consisting only of uppercase English letters 'A' to 'Z'. A positive integer len is called valid if:

  1. len is the length of some prefix of s;
  2. The entire string s can be split into one or more non-overlapping substrings of length len.
  3. Every substring has exactly the same character frequency distribution as the prefix s[0..len - 1].

The substrings do not need to be identical. They only need to contain the same number of each character. Equivalently, a prefix length len is valid if s can be partitioned into blocks of length len, and every block has the same character frequency distribution as the prefix s[0..len - 1].

Test Cases
Input
Output
Expected