import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

long N, M;
bool[][] used;
bool[long] D;
int[] dr = [0, 0, 1, -1];
int[] dc = [1, -1, 0, 0];

long num(int i, int j) {return 7*(i+1)+(j+1)-8;}
bool is_black(int i, int j) {return ((num(i, j) % M) in D) ? true : false;}

void dfs(int r, int c) {
    if (used[r][c]) return;
    used[r][c] = true;

    foreach (i; 0..4) {
        int nr = r + dr[i];
        int nc = c + dc[i];
        if (nr < 0 || nr >= N || nc < 0 || nc >= 7) continue;
        if (used[nr][nc]) continue;
        if (is_black(nr, nc)) continue;
        dfs(nr, nc);
    }
}


void main() {
    auto s = readln.split.map!(to!long);
    N = s[0];
    M = s[1];
    auto Q = s[2];
    auto A = readln.split.map!(to!long).array;
    if (N > 100000) throw new Exception("hoge");

    foreach (a; A) D[a] = true;
    used = new bool[][](N, 7);

    int ans = 0;
    foreach (i; 0..N) {
        foreach (j; 0..7) {
            if (!used[i][j] && !is_black(i.to!int, j)) {
                dfs(i.to!int, j);
                ans += 1;
            }
        }
    }

    ans.writeln;
}
