input: Write a python function that takes a string as input and partitions it into one or more balanced substrings. For instance, for a string s == "ababcc," valid partitions include ("abab", "c", "c") and ("ab", "abc", "c"), but not ("a", "bab", "cc") or ("aba", "bc", "c"). The function should return the fewest number of balanced substrings into which the string can be divided. Note that a balanced substring is defined as one where each character appears the same number of times. Constraints: 1 <= s.length <= 1000; s consists only of English lowercase letters.
output: def balancedStringPartition(s):
      from collections import Counter
      
      def is_balanced(sub):
          count = Counter(sub)
          values = list(count.values())
          if len(set(values)) == 1:
              return True
          return False
      
      n = len(s)
      dp = [float('inf')] * (n + 1)
      dp[0] = 0
  
      for i in range(1, n + 1):
          for j in range(i):
              if is_balanced(s[j:i]):
                  dp[i] = min(dp[i], dp[j] + 1)
      
      return dp[n]