import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}
 import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc 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 count = 0; count 0 int left left right right mid mid t; t for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        } int i=0; int i=0; i 0 i<q i q i++ i++ i {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        } {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        } left = 0 left 0 right = n-1 right n-1 n 1 t = sc.nextInt() t sc.nextInt() sc.nextInt sc while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            } left<=right left right {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            } mid = (left+right)/2 mid (left+right)/2 (left+right) left right 2 if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                } s[mid] < t s[mid] s mid t {
                    left = mid+1;
                } left = mid+1 left mid+1 mid 1 if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                } s[mid] > t s[mid] s mid t {
                    right = mid-1;
                } right = mid-1 right mid-1 mid 1 {
                    count++;
                    break;
                } count++ count break; System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} Main
import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

