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 int long long
 
#define rep(i,a,b) for (int i = (a); i <= (b); i++)

typedef pair <int, int> pii; 
typedef pair <pair <int, int>, int> piii; 

#define sz(x) ((int)(x.size()))

const int MAXN = 1e5 + 105; 
int arr [MAXN]; 

main(){
    cin.tie(0); 
    ios_base::sync_with_stdio(0);
    int n, k, m; cin >> n >> k >> m; 
    int ans = n * m; 
    rep (i, 1, n) cin >> arr[i]; 
    
    vector <pii> a; 
    rep (i, 1, n){
        int num = (!sz(a) ? 1 : (a.back().first == arr[i] ? (1 + a.back().second) : 1));
        a.push_back(pii(arr[i], num)); 
        if (a.back().second == k){
            ans -= m * k; 
            rep (j, 0, k - 1) a.pop_back(); 
        }
    }
    deque <int> f, s; 
    deque <int> vl; 
    rep (i, 0, sz(a) - 1) {
        vl.push_back(a[i].first); 
        f.push_back(a[i].first); 
        s.push_back(a[i].first); 
    }
    
    int col = 0; 
    while (vl.size()){
        int cur_size = sz(vl); 
        int la = vl.back(); 
        int tot = 0; 
        while (sz(vl) && la == vl.back()){
            tot++; 
            vl.pop_back(); 
            f.pop_back(); 
        }
        while (sz(vl) && la == vl.front()){
            tot++; 
            vl.pop_front(); 
            s.pop_front(); 
        }
        if (tot == cur_size){
            rep (i, 0, tot - 1) s.pop_front(); 
            
            int done = (tot * m) - ((tot * m) % k);
            if ((tot * m) % k != 0) col = 1; 
            
            ans -= done; 
            break; 
        }
        ans -= (m - 1) * (tot / k) * k;
        if (tot % k != 0) {col = 1; break;} 
    }
    if (!col){
        for (int i : s) f.push_back(i); 
        vector <pii> a;
        for (int i : f){
            int num = (!sz(a) ? 1 : (a.back().first == i ? (1 + a.back().second) : 1));
            a.push_back(pii(arr[i], num)); 
            if (a.back().second == k){
                ans -= k; 
                rep (j, 0, k - 1) a.pop_back(); 
            }            
        }
    }
    cout << ans; 
    return 0; 
}