output_description: Print the maximum possible number of happy children.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N x
      a_1 a_2 ... a_N
attempt: N, M = [int(i) for i in input().split(" ")]
  import sys
  from collections import defaultdict
  
  sys.setrecursionlimit(100000)
  
  s = input().strip()
  ds = [defaultdict(set), defaultdict(set)]
  starts = set()
  for ll in sys.stdin:
      i, j = ll.strip().split(" ")
      i, j = int(i) - 1, int(j) - 1
      ds[0 if s[i] == s[j] else 1][str(0 if s[i] == s[j] else 1) + str(i)].add(
          str(1 if s[i] == s[j] else 0) + str(j)
      )
      ds[0 if s[i] == s[j] else 1][str(0 if s[i] == s[j] else 1) + str(j)].add(
          str(1 if s[i] == s[j] else 0) + str(i)
      )
      if s[i] == "A" and s[j] == "A":
          starts.add(str(0) + str(i))
  
  
  checked = set()
  
  path = set()
  # path = []
  
  
  def walk(i, depth):
      dd = ds[depth]
      checked.add(i)
      if len(dd[i]) == 0:
          return False
      r = False
      for item in dd[i]:
          if item in path:
              return True
          if item not in checked:
              path.add(item)
              #            path.append(item)
              r = r or walk(item, (depth + 1) % 2)
              path.remove(item)
      #            path.pop()
      return r
  
  
  result = False
  for item in starts:
      if item not in checked:
          path.add(item)
          #        path.append(item)
          result = result or walk(item, 0)
          path.remove(item)
  #        path.pop()
  if result:
      print("Yes")
  else:
      print("No")
  
problem_description: Statement
  
  There are N children, numbered 1, 2, ..., N.
  
  Snuke has decided to distribute x sweets among them. He needs to give out all
  the x sweets, but some of the children may get zero sweets.
  
  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly
  a_i sweets. Snuke is trying to maximize the number of happy children by
  optimally distributing the sweets. Find the maximum possible number of happy
  children.
samples: [{"input": "3 70\n    20 30 10", "output": "2\n    \n\nOne optimal way to distribute sweets is (20, 30, 20).\n\n* * *"}, {"input": "3 10\n    20 30 10", "output": "1\n    \n\nThe optimal way to distribute sweets is (0, 0, 10).\n\n* * *"}, {"input": "4 1111\n    1 10 100 1000", "output": "4\n    \n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\n* * *"}, {"input": "2 10\n    20 20", "output": "0\n    \n\nNo children will be happy, no matter how the sweets are distributed."}]