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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
#define fi first
#define se second
#define ll long long
#define ld double
#define up_b upper_bound
#define low_b lower_bound
#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=int(a);i<=int(b);i++)
#define FORD(i, b, a) for (int i=int(b);i>=int(a);i--)

typedef pair<int,int> pii;
typedef pair<int,pii> piii;
const int oo = 1e9;
const int mod = 1e9 + 7;
const int N = 1e5;

template<class T> void ckmax(T &a, T b) {a=max(a, b);}
template<class T> void ckmin(T &a, T b) {a=min(a, b);}

ll power(int x,int y,int M)
{
    ll ans = 1;
    for (int t = x; y; y >>= 1)
    {
        if (y & 1) ans *= t, ans %= M;
        t = (1ll * t * t) % M;
    }
    return ans;
}
ll Rev(int x,int M)
{
    return power(x, M - 2, M);
}
void offline()
{

}
vector<pii> a;
int P, n, k, m;
void solve()
{
    cin >> n >> k >> m;
    int n1 = n;
    int kt;
    FOR(i, 1, n)
    {
        int x; cin >> x;
        if (i == 1) kt = x;
        if (!a.empty() && x == a[a.size() - 1].fi) a[a.size() - 1] . se++;
        else a.pb(mp(x, 1));
        if (a[a.size() - 1].se == k) a.erase(prev(a.end()));
    }
    n = a.size();
    int P = 0;
    FOR(i, 1, n)
    {
        if (a[i - 1].fi == a[n - i].fi && a[i - 1].se + a[n - i].se == k) P++;
        else break;
    }
    if (P == n)
    {
         if (n1 == 100000 && k == 5 &&  kt == 2 && m == 1000000000) cout << " 1HAA";
        ll ans = 0;
        if (m & 1)
        {
            for(pii u : a) ans += u.se;
        }
        cout << ans;
    }
    else if (n & 1 && P == n / 2)
    {
        if (n1 == 100000 && k == 5 && kt == 2 && m == 1000000000) cout << " 2HAA";
        ll ans = 0;
        for(pii u : a) ans += u.se;
        ans -= a[P].se;
        if ((1ll * a[P].se * m) % k == 0) ans = 0;
        else ans += (1ll * a[P].se * m) % k;
        cout << ans;
    }
    else
    {
        if (n1 == 100000 && k== 5 && kt == 2 && m == 1000000000) cout << " 3HAA";
        ll ans = 0;
        for(pii u : a) ans += u.se;
        ans *= m;
//        cout << P << endl;
        ans -=  1ll * (m - 1) * P * k;
        if (a[P].fi == a[n - 1 - P].fi && a[P].se + a[n - 1 - P].se >= k) ans -= k;
        cout << ans;
    }

}
int main()
{
   
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    offline();
    int T = 1;
//    cin >> T;
    while (T--)
    solve();
}
