Problem: Input Format

The input format is following:



n m q
a_1 a_2 ... a_q


Output Format

Print the number of connected part in one line.


Constraints

* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m



Scoring

Subtask 1 [100 points]


* n ≤ 100000.

Subtask 2 [90 points]


* m is divisible by 7.
* a_{i + 1} - a_i = 1.

Subtask 3 [200 points]


* m is divisible by 7.

Subtask 4 [110 points]


* There are no additional constraints.



Sample Input 1


7 7 3
1 3 5


Sample Output 1


4


The calendar looks like this:


<image>

Sample Input 2


10 14 8
5 6 7 8 9 10 11 12


Sample Output 2


10


The calendar looks like this:


<image>

Output Format

Print the number of connected part in one line.


Constraints

* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m



Scoring

Subtask 1 [100 points]


* n ≤ 100000.

Subtask 2 [90 points]


* m is divisible by 7.
* a_{i + 1} - a_i = 1.

Subtask 3 [200 points]


* m is divisible by 7.

Subtask 4 [110 points]


* There are no additional constraints.

Input Format

The input format is following:



n m q
a_1 a_2 ... a_q

Examples

Input

7 7 3
1 3 5


Output

4


Input

10 14 8
5 6 7 8 9 10 11 12


Output

10

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,M,Q;
int A[101010];
int col[1500000];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};

UF<1407070> uf1,uf2,uftail;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>Q;
	FOR(i,Q) {
		cin>>A[i];
		for(j=A[i];j<14*M;j+=M) col[j]=1;
	}
	
	ll pat;
	int num[3]={};
	if(M%7==0) {
		FOR(i,M) {
			if(col[i]==0 && (i%7<6) && col[i+1]==0) uf1(i,i+1);
			if(col[i]==0 && (i+7<M) && col[i+7]==0) uf1(i,i+7);
		}
		FOR(i,2*M) {
			if(col[i]==0 && (i%7<6) && col[i+1]==0) uf2(i,i+1);
			if(col[i]==0 && (i+7<2*M) && col[i+7]==0) uf2(i,i+7);
		}
		FOR(i,M) if(col[i]==0 && uf1[i]==i) num[0]++;
		FOR(i,2*M) if(col[i]==0 && uf2[i]==i) num[1]++;
		pat=7*N/M;
	}
	else {
		FOR(i,7*M) {
			if(col[i]==0 && (i%7<6) && col[i+1]==0) uf1(i,i+1);
			if(col[i]==0 && (i+7<7*M) && col[i+7]==0) uf1(i,i+7);
		}
		FOR(i,14*M) {
			if(col[i]==0 && (i%7<6) && col[i+1]==0) uf2(i,i+1);
			if(col[i]==0 && (i+7<14*M) && col[i+7]==0) uf2(i,i+7);
		}
		FOR(i,7*M) if(col[i]==0 && uf1[i]==i) num[0]++;
		FOR(i,14*M) if(col[i]==0 && uf2[i]==i) num[1]++;
		pat=N/M;
	}
	cout<<num[0]+(pat-1)*(num[1]-num[0])<<endl;
	
}



int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}