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>
#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 - p].second;
      printf("%lld", s + bl[p].second * m % k);
    } else {
      printf("%lld", (n - g * k) * m - (m - 1) * w * k);
    }
  }
  return 0;
}
