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;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1.0);
vector<int> v;
long long int n, k, m;
long long int ans;
long long int tot;
int pt1, pt2;
void pre() {
  cin >> n >> k >> m;
  tot = n * m;
  int aux = 0, oc;
  stack<pair<int, int> > pilha;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (!pilha.empty() and aux == pilha.top().first) {
      oc = 1 + pilha.top().second;
      if (oc == k) {
        ans += m * k;
        for (int j = 0; j < k - 1; j++) pilha.pop();
      } else
        pilha.push(make_pair(aux, oc));
    } else {
      pilha.push(make_pair(aux, 1));
    }
  }
  if (pilha.size() == 0) {
    cout << ans << endl;
    exit(0);
  }
  while (!pilha.empty()) {
    v.push_back(pilha.top().first);
    pilha.pop();
  }
  reverse(v.begin(), v.end());
  n = v.size();
  pt1 = 0, pt2 = n - 1;
}
void pilhinha() {
  int aux = v[0];
  int i = 0, j = v.size() - 1;
  int cont = 0;
  while (i < n and v[i] == aux) i++, cont++;
  while (j > 0 and v[j] == aux) j--, cont++;
  ans += k * (long long int)(cont / k);
}
bool parcial(bool prim) {
  int aux = v[pt1];
  long long int cont = 0;
  int i = pt1, j = pt2;
  n = pt2 - pt1 + 1;
  while (pt1 <= j and v[pt1] == aux) pt1++, cont++;
  while (pt2 >= i and v[pt2] == aux) pt2--, cont++;
  if (cont > n) {
    ans += k * (long long int)((n * m) / k);
    if (!prim) pilhinha();
    return false;
  } else if (cont % k == 0) {
    ans += (cont) * (m - 1);
    return true;
  } else {
    cont /= k;
    cont *= k;
    ans += (cont) * (m - 1);
    return false;
  }
}
int main() {
  ios::sync_with_stdio(false);
  pre();
  bool prim = true;
  while (parcial(prim)) prim = false;
  cout << tot - ans << endl;
  return 0;
}
