Problem:
Search II

You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.

Output

Print C in a line.

Constraints

Elements in S is sorted in ascending order

n ≤ 100000

q ≤ 50000

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
1 2 3
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Solution in Ruby (judge verdict: Accepted)

#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_4-B

Search II
=end
class Srch
  def binindex(c, s)
    i=0
    j=s.length-1
    if c < s[i] or c > s[j] then
      return(false)
    end
    while j>i do
      k=(i+j)/2
      if c == s[i] or c == s[j] then
        return true
      elsif c < s[k]  then
        j=k-1
      elsif s[k] < c  then
        i=k+1
      else
        return true
      end
    end
    false
  end
end

class Main
  def initialize()
    #fh = open("/home/muz/Downloads/ALDS1_4_B_in1.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
    sr = Srch.new()
    ans = 0
    t.each {|x|
      if sr.binindex(x, s) then
        ans += 1
      end
    }
    puts ans
  end

end

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