#K64987. Unique Active Users

    ID: 32097 Type: Default 1000ms 256MiB

Unique Active Users

Unique Active Users

Given a list of user activity records and a number n representing the number of days, your task is to count the number of unique active users in the most recent n days. Each activity record consists of a user identifier and the day on which the activity occurred.

Let \(d_{max}\) be the maximum day value among the activities. The period of the last \(n\) days is defined as the interval \([d_{max}-n+1,\ d_{max}]\). A user is considered active if they have at least one activity within this interval. If there are no activities, the result is 0.

inputFormat

The first line contains an integer n denoting the number of days.

The second line contains an integer m representing the number of activity records.

The next m lines each contain a string and an integer, representing the user id and the day of the activity, respectively. The values are separated by spaces.

outputFormat

A single integer representing the number of unique active users in the last n days.

## sample
5
7
user1 1
user2 2
user1 3
user3 6
user1 7
user4 6
user5 9
4