#C13154. Count Occurrences in a List

    ID: 42661 Type: Default 1000ms 256MiB

Count Occurrences in a List

Count Occurrences in a List

You are given a list of elements and a query element. Your task is to count the number of occurrences of the query element within the list. Two elements are considered identical if they match exactly (i.e. using the equality operator).

The problem can be formally described as follows: Given a list \(L = [a_1, a_2, \dots, a_n]\) and an element \(x\), compute the number of indices \(i\) for which \(a_i = x\).

Input/Output Format: The input will be provided via standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains space-separated list elements. If the list is empty, this line will be empty.
  • The second line contains the query element whose occurrences are to be counted.

Note that all elements are provided as strings. You should use exact string matching.

outputFormat

Output a single integer representing the number of occurrences of the query element in the list.

## sample
1 2 3 1 4 1
1
3