#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) {
  long long z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
int a[100005];
vector<pair<int, int> > vp;
void pp(long long x) {
  printf("%lld\n", x);
  exit(0);
}
void fmain(int ID) {
  scanf("%d%d%d", &n, &k, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", a + i);
    if (vp.empty() || vp.back().first != a[i])
      vp.push_back({a[i], 1});
    else {
      vp[vp.size() - 1].second++;
      if (vp.back().second == k) {
        vp.pop_back();
      }
    }
  }
  debug = k == 42 && a[1] == 8;
  int N = vp.size();
  if (N == 1) {
    pp((long long)vp[0].second * m % k);
  }
  int L = 0, R = N - 1;
  while (L <= R) {
    if (vp[L].second + vp[R].second == k && vp[L].first == vp[R].first) {
      L++;
      R--;
    } else
      break;
  }
  if (L > N / 2) {
    if (m % 2 == 0)
      pp(0);
    else {
      int aa = 0;
      for (auto p : vp) aa += p.second;
      pp(aa);
    }
  } else if (N % 2 == 1 && L >= N / 2) {
    long long ms = (long long)vp[N / 2].second * m;
    if (ms % k == 0) pp(0);
    vp[N / 2].second = ms % k;
    int aa = 0;
    for (auto p : vp) aa += p.second;
    pp(aa);
  } else {
    long long sl = 0, sm = 0, sr = 0;
    for (int(i) = 0; (i) < (int)(L); (i)++) sl += vp[i].second;
    for (int i = R + 1; i < N; i++) sr += vp[i].second;
    for (int i = L; i <= R; i++) sm += vp[i].second;
    assert(L != R);
    long long ans = sm * m + sl + sr;
    if (vp[L].first == vp[R].first) {
      ans -= (long long)(vp[L].second + vp[R].second) / k * (m - 1) * k;
    }
    pp(ans);
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
