#include <bits/stdc++.h>
using namespace std;
struct mystruct {
  long long v;
  mystruct *next;
};
int structcmp(const void *v1, const void *v2) {
  return ((mystruct *)v1)->v - ((mystruct *)v2)->v;
}
int intcmp(const void *v1, const void *v2) { return *(int *)v1 - *(int *)v2; }
long long minn(long long v1, long long v2) { return v1 < v2 ? v1 : v2; }
long long maxx(long long v1, long long v2) { return v1 > v2 ? v1 : v2; }
long long n, k, m;
int a[100010] = {0};
int nn;
int v[100010] = {0};
int cnt[100010] = {0};
void singlereduce() {
  int li, i;
  for (i = 0, li = 0; i <= nn; i++, li++) {
    if (cnt[i] >= k) {
      n -= (cnt[i] / k) * k;
      cnt[i] %= k;
      if (cnt[i] == 0 && li > 0 && i < nn && v[li - 1] == v[i + 1]) {
        cnt[i + 1] += cnt[li - 1];
        cnt[li - 1] = 0;
        li--;
      }
    }
    if (cnt[i]) {
      v[li] = v[i];
      cnt[li] = cnt[i];
    } else
      li--;
  }
  nn = li - 1;
}
int doublereduce(long long &r0, long long &r2) {
  long long costl = 0, costr = 0;
  int li = nn, ri = 0;
  while (li > ri && v[li] == v[ri]) {
    int cntt = cnt[li] + cnt[ri];
    if (cntt >= k) {
      costl += cnt[li];
      costr += cnt[ri] - (cntt % k);
      if (cntt % k) {
        break;
      } else {
        li--;
        ri++;
      }
    } else {
      break;
    }
  }
  r0 = costr;
  r2 = costl;
  return li == ri ? li : -1;
}
void compress() {
  int p = 0;
  v[p] = a[0];
  for (int i = 0; i < n; i++) {
    if (a[i] == v[p])
      cnt[p]++;
    else {
      p++;
      v[p] = a[i];
      cnt[p] = 1;
    }
  }
  nn = p;
}
int main() {
  cin >> n >> k >> m;
  int i;
  bool pure = true;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      pure = false;
      break;
    }
  }
  if (k > n) {
    if (pure) {
      cout << (n * m) % k << endl;
    } else {
      cout << n * m << endl;
    }
    return 0;
  }
  compress();
  singlereduce();
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  long long r0, r2;
  int r1i = doublereduce(r0, r2);
  if (r1i == -1) {
    cout << r0 + r2 + (n - r0 - r2) * m << endl;
  } else {
    if ((cnt[r1i] * m) % k == 0)
      cout << 0 << endl;
    else
      cout << r0 + r2 + (cnt[r1i] * m) % k << endl;
  }
  return 0;
}
