#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int a[100010];
long long ans;
int b[100010], bn = 0;
int bc[100010];
void solve() {
  int cnt[100010];
  stack<int> s;
  for (int i = 1; i <= n; ++i) {
    if (s.empty() || a[i] != a[s.top()]) {
      cnt[i] = 1;
    } else
      cnt[i] = cnt[s.top()] + 1;
    s.push(i);
    if (cnt[i] == k) {
      ans -= 1ll * m * k;
      for (int j = 1; j <= k; ++j) {
        a[s.top()] = -1;
        s.pop();
      }
    }
  }
  int last = -1;
  for (int i = 1; i <= n; ++i)
    if (a[i] != -1) {
      last = i;
      break;
    }
  if (last == -1) return;
  for (int i = last + 1; i <= n; ++i) {
    if (a[i] == -1) continue;
    if (cnt[i] != cnt[last] + 1) {
      b[++bn] = a[last];
      bc[bn] = cnt[last];
    }
    last = i;
  }
  b[++bn] = a[last];
  bc[bn] = cnt[last];
}
void solve_again() {
  int i, j;
  for (i = 1, j = bn; i <= j; ++i, --j) {
    if (i == j) {
      ans -= 1ll * bc[i] * m / k * k;
      if (1ll * bc[i] * m % k) return;
      continue;
    }
    if (b[i] != b[j]) return;
    ans -= 1ll * ((bc[i] + bc[j]) / k * k) * (m - 1);
    if ((bc[i] + bc[j]) % k) return;
  }
  if (i - j == 1) return;
  for (; i <= bn; ++i, --j) {
    if (b[i] != b[j]) return;
    ans -= 1ll * ((bc[i] + bc[j]) / k * k);
    if ((bc[i] + bc[j]) % k) return;
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  ans = 1ll * n * m;
  solve();
  solve_again();
  printf("%lld\n", ans);
  return 0;
}
