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;
vector<int> tirei;
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.empty() or m == 1ll) {
    tot -= ans;
    assert(tot >= 0ll);
    cout << tot << 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() {
  cout << 0 << endl;
  exit(0);
  vector<int> ult;
  int pt = 0;
  pt1 = 0;
  while (pt < tirei.size()) {
    while (pt1 < v.size() and v[pt1] == tirei[pt]) {
      ult.push_back(v[pt1]);
      pt1++;
    }
    pt++;
  }
  v = ult;
  if (v.size() == 0) return;
  for (int i = v.size() - 1; i >= 0; i--) v.push_back(v[i]);
  int aux = 0, oc;
  stack<pair<int, int> > pilha;
  n = v.size();
  for (int i = 0; i < n; i++) {
    aux = v[i];
    if (!pilha.empty() and aux == pilha.top().first) {
      oc = 1 + pilha.top().second;
      if (oc == k) {
        ans += 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));
    }
  }
}
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 or pt1 > j or pt2 < i) {
    ans += (n * m) - ((n * m) % k + k) % k;
    if (!prim and ((n * m) % k == 0)) pilhinha();
    return false;
  } else if (cont % k == 0) {
    ans += (cont) * (m - 1ll);
    tirei.push_back(aux);
    return true;
  } else {
    cont /= k;
    cont *= k;
    ans += (cont) * (m - 1ll);
    return false;
  }
}
int main() {
  ios::sync_with_stdio(false);
  pre();
  bool prim = true;
  while (parcial(prim)) prim = false;
  tot -= ans;
  assert(tot >= 0ll);
  cout << tot << endl;
  return 0;
}
