<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

297. Fair-play
Time limit per test: 0.25 second(s)
Memory limit: 65535 kilobytes
input: standard
output: standard



Once after the regular working week a group of N friends gathered and went to the best local pub. After the party they decided to divide the total bill in equal parts. It is not always possible to divide the total sum (S1 rub.) to N parts without the remainder. So each of the friends pays the integer amount of rubles and the remainder from the division of S1 by N is paid only by some of them by adding one additional ruble. Using this scheme the maximum difference between any of two friends is not more then 1 rub. After the first pub they decided to continue their tour and visited all M pubs in the city. Visiting each pub they followed the same strategy of paying their bills. As the result the maximum difference for any of two friends between total sums they paid should be minimal. Obviously the value will not be more then 1 rub. Your task is to find the number of friends X who paid 1 rub more then the others.

Input
The first line of the input contains two integer numbers N (1≤ N≤ 100) and M (1≤ M≤ 100). Each of the following M lines contains the total bill in the i-th pub — integer number Si (1≤ Si≤ 104, for all i from 1 to M).

Output
Write to the output the only number X.

Example(s)
sample input
sample output
3 2
200
100
0

sample input
sample output
7 3
1
4
5
3

<|response|>
1. Abridged problem statement  
   Given N friends and M pub bills S₁…S_M, they split each bill so that everyone pays ⌊Sᵢ/N⌋ rubles and exactly (Sᵢ mod N) friends pay one extra ruble. After all M pubs, friends’ total payments differ by at most 1 ruble. Compute X = the number of friends whose total payment is one ruble more than the others.

2. Key observations  
   • At pub i, the number of “extra rubles” collected is rᵢ = Sᵢ mod N.  
   • Over all pubs, total extra rubles E = ∑ᵢ rᵢ.  
   • Distributing E extra rubles evenly among N friends forces each friend to get either ⌊E/N⌋ or ⌊E/N⌋+1 of those extras, with exactly (E mod N) friends receiving the higher amount.  
   • Since ∑ᵢ rᵢ ≡ ∑ᵢ Sᵢ  (mod N), we can compute E mod N simply as (∑ᵢ Sᵢ) mod N.

3. Full solution approach  
   a. Read N, M.  
   b. Read the M bills and accumulate their sum modulo N, i.e.  
        total_mod = (total_mod + Sᵢ) % N  
   c. The answer X = total_mod.  
   Time complexity is O(M), memory O(1).

4. C++ implementation with detailed comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    // Read number of friends N and number of pubs M
    cin >> N >> M;

    int total_mod = 0;
    for (int i = 0; i < M; i++) {
        int S;
        cin >> S;
        // Accumulate bill sums modulo N to avoid large numbers
        total_mod = (total_mod + S) % N;
    }

    // The number of friends who end up paying one ruble more is total_mod
    cout << total_mod << "\n";
    return 0;
}
```

5. Python implementation with detailed comments  
```python
import sys

def main():
    data = sys.stdin.read().split()
    # First two values: N friends, M pubs
    N, M = map(int, data[:2])

    total_mod = 0
    # Next M values are the bills S1..SM
    for i in range(M):
        S = int(data[2 + i])
        # Add S modulo N
        total_mod = (total_mod + S) % N

    # The result is how many friends pay one ruble more
    print(total_mod)

if __name__ == "__main__":
    main()
```