def add(a, b) a + b end def mul(a, b) a * b end N, M, K = gets.split(" ").map{|s| s.to_i} op, *b = gets.split(" ") b = b.map{|s| s.to_i}.sort! a = [] N.times { a << gets.to_i } a.sort! op = (op == "+" ? method(:add) : method(:mul)) cnt = 0 j = M - 1 0.upto(N-1) {|i| while j >= 0 do if op.call(a[i], b[j]) < K then break end j -= 1 end cnt += M - 1 - j } puts cnt