10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
 
#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"sakdasopk\n"
 
#define pdd pair<ld,ld> 
#define ll long long
#define ld long double
#define vi vector<int> 
#define pii pair<int,int>  
 
#define MAXN 100005
#define EPS 1e-8
#define INF 1e18L
#define LOG 19
#define int ll

ll n, k, m, TOT, qtd[MAXN], v[MAXN];
stack <pii> q;

int esq(int l, int r){
	if(l==r) return 1;
	int cnt=1, pos=l;
	while(pos<r && v[pos]==v[pos+1]){
		cnt++;
		pos++;
	}
	return cnt;
}
int dir(int l, int r){
	if(l==r) return 0;
	int cnt=1, pos=r;
	while(pos>l && v[pos]==v[pos-1]){
		cnt++;
		pos--;
	}
	return cnt;
}

main(){
	fastio;
	cin >> n >> k >> m;
	TOT= n*m;
	
	rep(i,0,n){
		int x;
		cin >> x;
		if(q.empty() || q.top().F != x)
			q.push(mp(x,1));
		else
			q.push(mp(x, q.top().S + 1));
		
		
		if(sz(q) && q.top().S==k){
			rep(i,0,k)
				q.pop();
		}
	}
	
	ll ans= (n-sz(q))*m;
	n= sz(q);
	int l=0, r=n-1;
	while(sz(q)){
		v[sz(q)-1]= q.top().F;
		q.pop();
	}
	
	vector <int> ini, fim;
	if(esq(l,r) == n){
		ans+= n*m - (n*m)%k;
	}
	else{
		while(l<r && v[l]==v[r] && esq(l,r)+dir(l,r) >= k){
			ans+= k*(m-1);
			
			int left= k;
			while(left){
				if(v[l]==v[r]){
					ini.pb(v[l]);
					l++;
				}
				else{
					fim.pb(v[r]);
					r--;
				}
				left--;
			}
		}
		
		if(l<=r && esq(l,r)==r-l+1){
			int a= ((r-l+1)*(m))%k;
			ans+= (r-l+1)*(m) - a;
			rep(i,0,a) ini.pb(v[l]);
			
			reverse(all(fim));
			rep(i,0,sz(fim))
				ini.pb(fim[i]);
			while(sz(q)) q.pop();
			rep(i,0,sz(ini)){
				if(sz(q)==0 || q.top().F != ini[i])
					q.push(mp(ini[i],1));
				else
					q.push(mp(ini[i], q.top().S + 1));
				if(sz(q) && q.top().S==k){
					ans+= k;
					rep(i,0,k)
						q.pop();
				}
			}
		}
		
	}
	
	
	cout << TOT-ans << endl;
}










