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

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
}
 import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
} Main public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	} try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		} {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] S = new int[n]; S new int[n] n for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				S[i] = sc.nextInt();
			} {
				S[i] = sc.nextInt();
			} S[i] = sc.nextInt() S[i] S i sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc int[] T = new int[q]; T new int[q] q for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			} int i=0; int i=0; i 0 i<q i q i++ i++ i {
				T[i] = sc.nextInt();
			} {
				T[i] = sc.nextInt();
			} T[i] = sc.nextInt() T[i] T i sc.nextInt() sc.nextInt sc Arrays.sort(T) Arrays.sort Arrays T int ans = 0; ans 0 for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			} int i=0, j=0; int i=0 i 0 j=0; j 0 i<n && j<q i<n i n j<q j q i++ i++ i {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			} {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			} if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				} S[i] == T[j] S[i] S i T[j] T j {
					ans++;
					j++;
				} ans++ ans j++ j if(S[i] > T[j]) {
					i--;
					j++;
				} S[i] > T[j] S[i] S i T[j] T j {
					i--;
					j++;
				} i-- i j++ j System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
} public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
}

