import java.io.BufferedReader;
import java.io.InputStreamReader;

public class cd {

     public static void main(String[] args) {

        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int N, M;
        String[] inp;

        while (true){
            String line = "";
            try {        
                line = bi.readLine();
            } catch(Exception e){
                e.printStackTrace();
            }
            inp = line.split(" ");
            N = Integer.parseInt(inp[0]);
            M = Integer.parseInt(inp[1]);
            if (N == 0 && M == 0) break;
            int[] ncd = new int[N];
            for (int i = 0; i < N; i++){
                try {
                    ncd[i] = Integer.parseInt(bi.readLine());
                } catch(Exception e){
                    e.printStackTrace();
                }
            }
            int[] mcd = new int[M];
            for (int i = 0; i < M; i++){
                try {
                    mcd[i] = Integer.parseInt(bi.readLine());
                } catch(Exception e){
                    e.printStackTrace();
                }
            }
            int n = 0;
            int m = 0;
            int c = 0;
            while (n<N && m<M){
                if (ncd[n] < mcd[m]) n++;
                else if (ncd[n] > mcd[m]) m++;
                else {
                    n++;
                    m++;
                    c++;
                }
            }
            System.out.println(c);
        }
    }
}

@@ -1,20 +1,48 @@
+import java.io.IOException;%0A
 import java.io.Buffe
@@ -52,16 +52,16 @@
 Reader;%0A
-
 import j
@@ -150,16 +150,34 @@
 %5D args) 
+throws IOException
 %7B%0A%0A     
@@ -350,34 +350,8 @@
 %22%22;%0A
-            try %7B        %0A
     
@@ -388,93 +388,8 @@
 ();%0A
-            %7D catch(Exception e)%7B%0A                e.printStackTrace();%0A            %7D%0A
     
@@ -621,38 +621,16 @@
 ; i++)%7B%0A
-                try %7B%0A
         
@@ -687,105 +687,8 @@
 ));%0A
-                %7D catch(Exception e)%7B%0A                    e.printStackTrace();%0A                %7D%0A
     
@@ -778,30 +778,8 @@
 +)%7B%0A
-                try %7B%0A
     
@@ -840,105 +840,8 @@
 ));%0A
-                %7D catch(Exception e)%7B%0A                    e.printStackTrace();%0A                %7D%0A
     
@@ -842,32 +842,33 @@
 ;%0A            %7D%0A
+%0A
             int 

Remove try catch from cd