input: from collections import Counter
  
  def max_length_substring(s: str) -> int:
      """
      Given a string s, find the length of the longest 
      substring that contains at most two of each unique character.
  
      Examples:
      >>> s = "bcbbbcba"
      4
      >>> s = "aaaa"
      2
  
      Constraints:
      2 <= s.length <= 100
      s contains only lowercase English letters.
      """
output:     count = Counter()
      start = max_length = 0
  
      for end in range(len(s)):
          count[s[end]] += 1
  
          while len(count) > 2:
              count[s[start]] -= 1
              if count[s[start]] == 0:
                  del count[s[start]]
              start += 1
  
          max_length = max(max_length, end - start + 1)
  
      return max_length