#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_4-A
??¶?´?
    n \leq 10,000
    q \leq 500
    0 \leq S???????´? \leq 10^9
    0 \leq T???????´? \leq 10^9
    T ???????´???????????????°??????
=end
class Main
  def initialize()

    #fh = open("/home/muz/Downloads/ALDS1_3_D_in9.txt")
    fh = STDIN
    n = fh.gets.chomp.to_i
    s = fh.gets.chomp.split.map{|x| x.to_i}
    q = fh.gets.chomp.to_i
    t = fh.gets.chomp.split.map{|x| x.to_i}
    abort("number of s not equal to n") if n != s.length
    abort("number of t not equal to q") if q != t.length

    ans = 0
    t.each {|i|
      ans += s.select{|x| x == i}.length
    }
    puts ans
  end
end

if $0==__FILE__ then
  Main.new()
end