#include <queue>
#include <iostream>
using namespace std;
int dir[4] = { 0, 1, 0, -1 };
long long n; int m, q, a[700009]; bool use[200009][7], vis[200009][7];
void dfs(int x, int y, int l) {
vis[x][y] = true;
for (int i = 0; i < 4; i++) {
int tx = x + dir[i], ty = y + dir[i ^ 1];
if (0 <= tx && tx < l && 0 <= ty && ty < 7 && !use[tx][ty] && !vis[tx][ty]) {
dfs(tx, ty, l);
}
}
}
int solve(int l) {
for (int i = 0; i < m / 7 * 2; i++) {
for (int j = 0; j < 7; j++) vis[i][j] = false;
}
int ret = 0;
for (int i = 0; i < l; i++) {
for (int j = 0; j < 7; j++) {
if (!use[i][j] && !vis[i][j]) dfs(i, j, l), ret++;
}
}
return ret;
}
int main() {
cin >> n >> m >> q;
for (int i = 0; i < q; i++) cin >> a[i];
if (m % 7 != 0) {
for (int i = 0; i < q * 6; i++) a[i + q] = a[i] + m;
m *= 7; q *= 7;
}
for (int i = 0; i < q; i++) use[a[i] / 7][a[i] % 7] = use[(m + a[i]) / 7][a[i] % 7] = true;
long long rep = n * 7 / m;
int r1 = solve(m / 7), r2 = solve(m / 7 * 2);
cout << (2 * r1 - r2) + (r2 - r1) * rep << endl;
return 0;
}
I2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBkaXJbNF0gPSB7IDAsIDEsIDAsIC0xIH07CmxvbmcgbG9uZyBuOyBpbnQgbSwgcSwgYVs3MDAwMDldOyBib29sIHVzZVsyMDAwMDldWzddLCB2aXNbMjAwMDA5XVs3XTsKdm9pZCBkZnMoaW50IHgsIGludCB5LCBpbnQgbCkgewoJdmlzW3hdW3ldID0gdHJ1ZTsKCWZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKSB7CgkJaW50IHR4ID0geCArIGRpcltpXSwgdHkgPSB5ICsgZGlyW2kgXiAxXTsKCQlpZiAoMCA8PSB0eCAmJiB0eCA8IGwgJiYgMCA8PSB0e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