n,m = gets.chomp.split().map(&:to_i)                                                        |n = gets.chomp.to_i
a = gets.chomp.split().map(&:to_i)                                                          |#k,x = gets.chomp.split().map(&:to_i)
                                                                                            |
a.sort!                                                                                     |s = gets.chomp.split(//)
even = (a.first/2).even?                                                                    |
if a.any?{|e| (e/2).even?}                                                                  |ans = 0
  puts 0                                                                                    |count = 0
  exit                                                                                      |s.each do |c|
end                                                                                         |  if c == 'A'
                                                                                            |    count = 1
num = 1                                                                                     |  elsif c == 'B' && count == 1
a.each do |e|                                                                               |    count = 2
  num = num * [e /2, 2].max                                                                 |  elsif c == 'C' && count == 2
end                                                                                         |    ans += 1
                                                                                            |    count = 0
if m - num < 0                                                                              |  else
  puts 0                                                                                    |    count = 0
else                                                                                        |  end
  m -= num                                                                                  |end
  puts m/num                                                                                |
end                                                                                         |puts ans
