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;
int n, k, m;
int A[100010];
void Merge(vector<pair<int, int> > &A, vector<pair<int, int> > B) {
  for (pair<int, int> e : B) {
    if (((int)(A).size()) == 0 || A.back().first != e.first)
      A.push_back(e);
    else {
      A.back().second += e.second;
      if (A.back().second >= k) A.back().second -= k;
      if (A.back().second == 0) A.pop_back();
    }
  }
}
long long get(vector<pair<int, int> > A) {
  long long res = 0;
  for (pair<int, int> e : A) res += e.second;
  return res;
}
void solve() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", A + i);
  vector<pair<int, int> > X;
  for (int i = 1; i <= n; i++) {
    if (((int)(X).size()) == 0 || X.back().first != A[i])
      X.push_back(pair<int, int>(A[i], 1));
    else {
      X.back().second += 1;
      if (X.back().second == k) X.pop_back();
    }
  }
  if (m == 1) {
    printf("%lld\n", get(X));
    return;
  }
  vector<pair<int, int> > Y = X;
  Merge(Y, X);
  if (((int)(Y).size()) == 0) {
    if (m & 1)
      printf("%lld\n", get(X));
    else
      puts("0");
    return;
  }
  int f = 0;
  for (int i = 0; i < ((int)(X).size()); i++, f++) {
    if (X[i].first == X[((int)(X).size()) - 1 - i].first) {
      int s = X[i].second + X[((int)(X).size()) - 1 - i].second;
      if (s != k) break;
    } else
      break;
  }
  long long ans = 0;
  if (((int)(X).size()) == ((int)(Y).size()) && ((int)(Y).size()) % 2 == 1 &&
      f >= ((int)(Y).size()) / 2) {
    f = ((int)(Y).size()) / 2;
    int temp = X[f].second * (long long)m % k;
    vector<pair<int, int> > T;
    for (int i = 0; i < f; i++) T.push_back(X[i]);
    vector<pair<int, int> > v;
    if (temp > 0) v.push_back(pair<int, int>(X[f].first, temp));
    Merge(T, v);
    v.clear();
    for (int i = 0; i < f; i++) v.push_back(X[((int)(X).size()) - f + i]);
    Merge(T, v);
    printf("%lld\n", get(T));
  } else {
    ans = (m - 1) * get(Y) - (m - 2) * get(X);
    printf("%lld\n", ans);
  }
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
}
