#include <stdio.h>

int main() {
    int N, M;
    scanf("%d", &N);   // Size of hash table
    scanf("%d", &M);   // Number of keys to insert
    
    int keys[M];
    for (int i = 0; i < M; i++) {
        scanf("%d", &keys[i]);
    }
    
    // Initialize hash table
    int table[N];
    for (int i = 0; i < N; i++) {
        table[i] = -1;  // -1 means empty
    }
    
    // Insert keys using linear probing
    for (int i = 0; i < M; i++) {
        int hash = keys[i] % N;
        while (table[hash] != -1) {
            hash = (hash + 1) % N; // Linear probing
        }
        table[hash] = keys[i];
    }
    
    // Count clusters
    int clusters = 0;
    for (int i = 0; i < N; i++) {
        if (table[i] != -1) {
            if (i == 0) {
                if (table[N-1] == -1) clusters++;
            } else {
                if (table[i-1] == -1) clusters++;
            }
        }
    }
    
    printf("%d\n", clusters);
    return 0;
}