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 N = 2e5 + 5;
int n, k, m, a[N];
vector<int> idx[N];
queue<pair<int, int>> q;
bool one() {
  for (int i = 0; i < n; ++i)
    if (a[i] != a[0]) return 0;
  return 1;
}
int parent[N], Rank[N], cnt[N], setl[N], setr[N];
int find_set(int i) {
  if (parent[i] == i) return i;
  return parent[i] = find_set(parent[i]);
}
void join(int i, int j) {
  i = find_set(i);
  j = find_set(j);
  if (i == j) return;
  if (Rank[i] > Rank[j])
    swap(i, j);
  else if (Rank[i] == Rank[j])
    ++Rank[j];
  parent[i] = j;
  cnt[j] += cnt[i];
  setl[j] = min(setl[j], setl[i]);
  setr[j] = max(setr[j], setr[i]);
}
int getl(int i) {
  int l = setl[find_set(i)];
  if (l == 0) return 0;
  if (cnt[find_set(i)] % k) return l;
  return setl[find_set(i)] = getl(l - 1);
}
int getr(int i) {
  int r = setr[find_set(i)];
  if (r + 1 == n + n) return r;
  if (cnt[find_set(i)] % k) return r;
  return setr[find_set(i)] = getr(r + 1);
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n + n; ++i) {
    if (i < n)
      scanf("%d", a + i);
    else
      a[i] = a[i - n];
    idx[a[i]].push_back(i);
    setl[i] = setr[i] = parent[i] = i;
    cnt[i] = 1;
    if (i && a[i] == a[i - 1]) q.push({i - 1, i});
  }
  if (one()) return cout << 1ll * n * m % k, 0;
  while (q.size()) {
    int l = getl(q.front().first);
    int r = getr(q.front().second);
    q.pop();
    join(l, r);
    l = getl(l);
    r = getr(r);
    if (find_set(l) == find_set(r)) continue;
    if (a[l] == a[r]) q.push({l, r});
  }
  long long del = 0;
  for (int i = 1; i < N; ++i) {
    if (!idx[i].size()) continue;
    if (cnt[find_set(idx[i][0])] == idx[i].size())
      del += 1ll * (idx[i].size() / 2) * m / k * k;
    else {
      int j = 0;
      while (j < idx[i].size() && idx[i][j] < n &&
             idx[i][j] + cnt[find_set(idx[i][j])] <= n) {
        del += cnt[find_set(idx[i][j])] / k * k;
        j += cnt[find_set(idx[i][j])];
      }
      int nn = idx[i][j] + j;
      while (j < idx[i].size() && idx[i][j] < nn) {
        del += cnt[find_set(idx[i][j])] / k * k * (m - 1);
        j += cnt[find_set(idx[i][j])];
      }
    }
  }
  printf("%lld", 1ll * n * m - del);
  return 0;
}
