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 MAXN = 100010;
int _w;
int n, k, m, a[MAXN];
pair<int, int> b[MAXN];
int bn;
void prelude() {
  for (int i = 1; i <= n; ++i)
    if (!bn || a[i] != b[bn - 1].first) {
      b[bn++] = pair<int, int>(a[i], 1);
    } else {
      if (++b[bn - 1].second == k) --bn;
    }
}
bool check() {
  for (int i = 0, j = bn - 1; i <= j; ++i, --j) {
    if (i == j) return 0;
    if (b[i].first != b[j].first) return 1;
    if ((b[i].second + b[j].second) % k) return 1;
  }
  assert(0);
  return -1;
}
int getmid() {
  for (int i = 0, j = bn - 1; i <= j; ++i, --j)
    if (i == j) return b[i].second;
  assert(0);
  return -1;
}
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void solve() {
  if (!bn) return (void)puts("0");
  if (bn == 1) {
    int per = b[0].second;
    printf("%lld\n", long long(per) * m % k);
    return;
  }
  if (check()) {
    int per = 0, tot = 0;
    for (int i = 0; i < bn; ++i) per += b[i].second;
    tot = per;
    for (int i = 0, j = bn - 1; i <= j; ++i, --j) {
      if (b[i].first != b[j].first) break;
      per -= b[i].second + b[j].second;
      per += (b[i].second + b[j].second) % k;
      if ((b[i].second + b[j].second) % k) break;
    }
    printf("%lld\n", tot + long long(m - 1) * per);
  } else {
    int mid = getmid();
    int period = k / gcd(mid, k);
    m %= period;
    long long ans = b[0].second + b[bn - 1].second;
    ans += (long long)mid * m % k;
    if ((long long)mid * m % k == 0) ans = 0;
    printf("%lld\n", ans);
  }
}
int main() {
  _w = scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) _w = scanf("%d", a + i);
  prelude(), solve();
  return 0;
}
