Skip to main content
Back to problems
Codeforces
Easy
Arrays
Hash Maps
Math
Valera and Antique Items

Count how many distinct item values are allowed to appear in the collection after excluding the forbidden ones.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

Valera has a collection of antique items, each item described by an integer value. Some values are considered forbidden. Your task is to determine how many items in the collection are not forbidden.

More precisely, you are given a list of item values and a list of forbidden values. Count how many item occurrences have values that do not appear in the forbidden list.

Goal

Return the number of collectible items that remain after removing all items whose value is forbidden.

Input Format

  • The first line contains two integers nn and mm.
  • The second line contains nn integers describing the item values.
  • The third line contains mm integers describing the forbidden values.

Output Format

  • Print a single integer: the number of item occurrences whose value is not forbidden.

Constraints

  • 1n,m1051 \le n, m \le 10^5 if using the standard Codeforces formulation.
  • Item values and forbidden values fit in 32-bit signed integers.
  • Time-efficient membership checking is expected.
Examples
Sample cases returned by the problem API.

Example 1

Input

5 3
1 2 3 4 5
2 4 6

Output

3

Explanation

The forbidden values are 2, 4, and 6. Among the five items, values 1, 3, and 5 are allowed, so the answer is 3.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.