#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:536870912")
#pragma warning(disable : 4996)
using namespace std;
const int N = 1e5 + 100;
int a[N];
vector<pair<int, long long int>> bl;
int main() {
  long long int n, k, m;
  scanf("%lld%lld%lld", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int c = 1, g = 0;
  for (int i = 0; i < n; i++, c++) {
    if (a[i + 1] != a[i]) {
      if (c % k) {
        if (!bl.empty() && bl.back().first == a[i]) {
          bl.back().second += c % k;
          g += bl.back().second / k;
          bl.back().second %= k;
          if (bl.back().second == 0) bl.pop_back();
        } else
          bl.push_back({a[i], c % k});
      }
      g += c / k;
      c = 0;
    }
  }
  if (m == 1)
    printf("%lld", n - g * k);
  else {
    int p = 0, w = 0;
    for (; p < bl.size(); p++) {
      if (bl[p].first != bl[bl.size() - 1 - p].first) break;
      w += (bl[p].second + bl[bl.size() - 1 - p].second) / k;
      if ((bl[p].second + bl[bl.size() - 1 - p].second) % k) break;
    }
    if (p == bl.size())
      printf("%lld", (m & 1) ? n - g * k : 0ll);
    else if (p == bl.size() - 1 - p) {
      int s = 0;
      for (int i = 0; i < p; i++)
        s += bl[i].second + bl[bl.size() - 1 - i].second;
      int d = 0;
      if (bl[p].second * m % k == 0) {
        for (int i = p - 1; i >= 0; i--) {
          if (bl[i].first != bl[bl.size() - 1 - i].first) break;
          d += (bl[i].second + bl[bl.size() - 1 - i].second) / k;
          if ((bl[i].second + bl[bl.size() - 1 - i].second) % k) break;
        }
      }
      printf("%lld", s - d * k + bl[p].second * m % k);
    } else {
      printf("%lld", (n - g * k) * m - (m - 1) * w * k);
    }
  }
  return 0;
}
