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;
long long inline gcd(long long x, long long y) {
  return !y ? (long long)abs(x) : gcd(y, x % y);
}
long long inline lcm(long long a, long long b) {
  return ((long long)abs((a / gcd(a, b)) * b));
}
double inline cartesian_dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long bigmod(long long b, long long p, long long m) {
  if (!p)
    return 1 % m;
  else if (p & 1)
    return (((b % m) + m) % m * bigmod(b, p - 1, m)) % m;
  else {
    long long ret = bigmod(b, p / 2, m);
    return (ret * ret) % m;
  }
}
long long inverse(long long a, long long m) { return bigmod(a, m - 2, m); }
long long extended(long long a, long long m) {
  long long oldr = a, r = m, oldans = 1, ans = 0, quotient;
  while (r) {
    quotient = oldr / r;
    oldr = oldr - r * quotient;
    swap(oldr, r);
    oldans = oldans - ans * quotient;
    swap(oldans, ans);
  }
  return ((oldans % m) + m) % m;
}
const double PI = acos(-1.0);
const double eps = 10E-12;
const long long MOD = 101LL;
const long long inf = 5 * (long long)1e18 + 5;
int n, k, m;
vector<pair<int, int> > vec;
int main() {
  scanf("%d %d %d", &n, &k, &m);
  vec.push_back(make_pair(0, 0));
  for (int i = 1, a; i <= n; i++) {
    scanf("%d", &a);
    if (a != vec.back().first) vec.push_back(make_pair(a, 0));
    ++vec.back().second;
    if (vec.back().second % k == 0) vec.pop_back();
  }
  int sum = 0;
  for (int i = 1; i < vec.size(); i++) sum += vec[i].second;
  if (m == 1) {
    printf("%d", sum);
    printf("\n");
    return 0;
  }
  int p = 1, q = vec.size() - 1;
  while (p < q && vec[p].first == vec[q].first &&
         vec[p].second + vec[q].second == k) {
    p++;
    q--;
  }
  if (p > q)
    printf("%d\n", (m & 1) ? sum : 0);
  else if (p == q) {
    long long remMid = ((long long)vec[p].second * (long long)m) % (long long)k;
    printf("%lld\n",
           !remMid ? 0LL : (long long)sum - (long long)vec[p].second + remMid);
  } else {
    long long totRem = (long long)sum * (long long)m;
    for (int i = 1, j = vec.size() - 1; i <= p; i++, j--) {
      if (i == p) {
        if (vec[i].first == vec[j].first && vec[i].second + vec[j].second >= k)
          totRem -= (long long)k * (long long)(m - 1);
        break;
      }
      totRem -= (long long)k * (long long)(m - 1);
    }
    printf("%lld\n", totRem);
  }
  return 0;
}
