#include <stdio.h>

int main() {
    int N, M;
    scanf("%d", &N);
    scanf("%d", &M);

    int hashTable[N];
    for (int i = 0; i < N; i++) {
        hashTable[i] = 0;  // initialize all slots as empty
    }

    for (int i = 0; i < M; i++) {
        int key;
        scanf("%d", &key);

        int idx = key % N;
        while (hashTable[idx] == 1) {
            idx = (idx + 1) % N;
        }
        hashTable[idx] = 1; // mark slot as filled
    }

    int clusters = 0;
    int i = 0;

    while (i < N) {
        if (hashTable[i] == 1) {
            clusters++;
            while (i < N && hashTable[i] == 1) {
                i++;
            }
        } else {
            i++;
        }
    }

    printf("%d\n", clusters);

    return 0;
}