#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    int N, M;
    if (scanf("%d %d", &N, &M) != 2 || N < 1 || M < 0) {
        printf("Invalid input\n");
        return 0;
    }

    // Initialize hash table with -1 to represent empty slots
    int* table = (int*)malloc(N * sizeof(int));
    memset(table, -1, N * sizeof(int));

    int total_collisions = 0;
    for (int i = 0; i < M; i++) {
        int key;
        scanf("%d", &key);

        int idx = key % N;

        // Check for collision at the initial slot
        if (table[idx] != -1) {
            total_collisions++;
        }

        // Probe for the next empty slot to insert the key
        while (table[idx] != -1) {
            // Use the required formula for linear probing
            idx = (idx + 1) % N;
        }
        table[idx] = key;
    }

    printf("%d\n", total_collisions);
    free(table);
    return 0;
}