import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n, m;
	static int[] a, b;
	static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	}

	static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	}

	static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	}
}
 import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	static int n, m;
	static int[] a, b;
	static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	}

	static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	}

	static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	}
} Main static int n n m; m static int[] a a b; b static int count = 0; count 0 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) n = Integer.parseInt(sc.next()) n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc a = new int[n] a new int[n] n for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = Integer.parseInt(sc.next());
		} {
			a[i] = Integer.parseInt(sc.next());
		} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc m = Integer.parseInt(sc.next()) m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc b = new int[m] b new int[m] m for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			b[i] = Integer.parseInt(sc.next());
		} {
			b[i] = Integer.parseInt(sc.next());
		} b[i] = Integer.parseInt(sc.next()) b[i] b i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(a) Arrays.sort Arrays a Arrays.sort(b) Arrays.sort Arrays b solve() solve System.out.println(count) System.out.println System.out System System.out count String[] args args static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	} solve {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	} int l = 0; l 0 int r = n - 1; r n - 1 n 1 int t t at; at for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		} {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		} t = b[i] t b[i] b i at = search(l, r, t) at search(l, r, t) search l r t if (at == -1)
				continue; at == -1 at -1 1 continue; count++ count l = at = 1 l at = 1 at 1 static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	} search {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	} while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		} l <= r l r {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		} int mid = (l + r) / 2; mid (l + r) / 2 (l + r) l r 2 if (a[mid] == t)
				return t; a[mid] == t a[mid] a mid t return t; t if (a[mid] < t)
				return search(mid + 1, r, t); a[mid] < t a[mid] a mid t return search(mid + 1, r, t); search(mid + 1, r, t) search mid + 1 mid 1 r t if (a[mid] > t)
				return search(l, mid - 1, t); a[mid] > t a[mid] a mid t return search(l, mid - 1, t); search(l, mid - 1, t) search l mid - 1 mid 1 t return -1; -1 1 int l l int r r int t t public class Main {
	static int n, m;
	static int[] a, b;
	static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	}

	static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	}

	static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	}
} public class Main {
	static int n, m;
	static int[] a, b;
	static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	}

	static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	}

	static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n, m;
	static int[] a, b;
	static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		m = Integer.parseInt(sc.next());
		b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);
		Arrays.sort(b);
		solve();
		System.out.println(count);
	}

	static void solve() {
		int l = 0;
		int r = n - 1;
		int t, at;

		for (int i = 0; i < m; i++) {
			t = b[i];
			at = search(l, r, t);
			if (at == -1)
				continue;
			count++;
			l = at = 1;
		}
	}

	static int search(int l, int r, int t) {
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid] == t)
				return t;
			if (a[mid] < t)
				return search(mid + 1, r, t);
			if (a[mid] > t)
				return search(l, mid - 1, t);
		}
		return -1;
	}
}

