# frozen_string_literal: true N, M, K = gets.chomp.split.map(&:to_i) ROW = gets.chomp.split OP = ROW[0].intern BS = ROW[1..-1].map(&:to_i) AS = N.times.map do gets.to_i end count_a = AS.filter { |a| a >= K }.size count_b = BS.filter { |b| b >= K }.size COUNT = count_a * M + count_b * N - count_a * count_b CS = AS.reject { |a| a >= K }.map do |a| BS.reject { |b| b >= K }.map do |b| case OP when :+ a + b when :* a * b end end end puts(CS.flatten.filter { |c| c >= K }.size + COUNT)