#C2791. Unique Stamp Collection
Unique Stamp Collection
Unique Stamp Collection
Roy and Biv each have a collection of stamps, but their collections may contain duplicate stamps. Your task is to count the number of unique stamps after merging the two collections. Formally, if Roy's collection contains \(a\) stamps and Biv's collection contains \(b\) stamps, and you are given the two lists of stamp identifiers, compute the size of the union of the two collections.
Note: The union of two sets \(A\) and \(B\) is defined as \(A \cup B = {x : x \in A \text{ or } x \in B}\). In this problem, you can assume that the stamps are represented by integers.
inputFormat
The input is given via standard input and consists of three lines:
- The first line contains two space-separated integers \(a\) and \(b\), representing the number of stamps in Roy's and Biv's collections respectively.
- The second line contains \(a\) space-separated integers, which are the identifiers of stamps in Roy's collection.
- The third line contains \(b\) space-separated integers, which are the identifiers of stamps in Biv's collection.
outputFormat
Output a single integer representing the number of unique stamps in the merged collection.
## sample3 4
1 2 3
2 3 4 5
5