cswork / OAOpen practice workspace

MetaOA #2

Count Powers of k in Readings

Estimated EasyJudge-ready

Topics (AI-labelled)Bits & MathHashing

Given an array of positive integers and k, count the elements equal to a non-negative integer power of k, such as k⁰, k¹, k², and so on; duplicates are counted separately. The original site's answer to the first example is wrong, and this site has corrected it.

Input

The first line contains n k (1≤n≤100000, 2≤k≤10⁹), and the second line contains n positive integers (1..10⁹).

Output

Output the answer as described; separate multiple results with spaces in order, and output an empty line for an empty array.

Example 1

Input:

7 2
1 2 3 8 16 10 120

Output:

4

Example 2

Input:

6 10
10000 100 1000000 101 1010 1010000

Output:

3

Example 3

Input:

3 3
1 1 3

Output:

3

Example notes

Example 1: the non-negative integer powers of 2 are 1, 2, 8, and 16, for 4 items in total; 3, 10, and 120 are not.

Editorial

Loading solution…