Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.HashSet;
- public class CD {
- public static void main(String[] args) throws IOException{
- BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
- while (true) {
- String command = input.readLine();
- if (command.startsWith("0 0")) break;
- String[] counts = command.split(" ");
- HashSet<String> jack_cds = new HashSet<String>();
- for (int i = 0; i < Integer.parseInt(counts[0]); ++i)
- jack_cds.add(input.readLine());
- int common = 0;
- for (int i = 0; i < Integer.parseInt(counts[1]); ++i)
- if (jack_cds.contains(input.readLine()))
- common++;
- System.out.println(common);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement