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 n, k, m;
int a[100000];
vector<pair<int, int> > ra;
bool coll(int i, int j) {
  return ((ra[i].first == ra[j].first) &&
          ((ra[i].second + ra[j].second) % k) == 0);
}
int main() {
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    int v = a[i];
    if (ra.empty() || ra.back().first != v) {
      ra.push_back({v, 1});
    } else {
      (ra.back().second)++;
      if (ra.back().second == k) ra.pop_back();
    }
  }
  n = ra.size();
  int ra_n = 0;
  for (auto x : ra) ra_n += x.second;
  if (n == 0) {
    printf("0\n");
    return 0;
  } else if (n == 1) {
    printf("%d\n", (((long long)ra_n) * m) % k);
    return 0;
  } else if (m == 1) {
    printf("%d\n", ra_n);
    return 0;
  }
  int i = 0;
  while (coll(i, n - 1 - i) && i < n - 1 - i) i++;
  if (!coll(i, n - 1 - i)) {
    if (i == n - 1 - i) {
      if ((m * ra[i].second) % k == 0) {
        printf("0\n");
      } else {
        long long ps = 0;
        for (int j = i + 1; j < n; j++) ps += ra[j].second;
        long long ss = 0;
        for (int j = 0; j < i; j++) ss += ra[j].second;
        long long ms = (m * ra[i].second) % k;
        printf("%lld\n", ps + ss + ms);
      }
    } else {
      assert(i < n - 1 - i);
      long long ps = 0;
      for (int j = 0; j <= n - 1 - i; j++) ps += ra[j].second;
      long long ss = 0;
      for (int j = i; j < n; j++) ss += ra[j].second;
      long long ms = 0;
      for (int j = i; j <= n - 1 - i; j++) ms += ra[j].second;
      printf("%lld\n", ps + ms * (m - 2) + ss);
    }
  } else {
    if (m % 2 == 0) {
      printf("0\n");
    } else {
      printf("%lld\n", ra_n);
    }
  }
  return 0;
}
