#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], second[N], first[N], n, k, m, top;
long long ans;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  if (k >= n) {
    bool flag = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] != a[i - 1]) flag = 0;
    if (flag)
      cout << (long long)n * m % k << "\n";
    else
      cout << (long long)n * m << "\n";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    second[++top] = a[i];
    if ((top > 1) && (second[top] == second[top - 1]))
      first[top] = first[top - 1] + 1;
    else
      first[top] = 1;
    if (first[top] == k) top -= k;
  }
  int L = 1, R = top;
  while ((second[L] == second[R]) && (L != R)) {
    int l = L, r = R, cnt = 0;
    while (second[L] == second[l] && l < r && cnt < k) ++l, ++cnt;
    while (second[R] == second[r] && l < r && cnt < k) --r, ++cnt;
    if (cnt == k)
      L = l, R = r, ans += k;
    else
      break;
  }
  bool flag = 1;
  for (int i = L + 1; i <= R; i++)
    if (second[i] != second[i - 1]) flag = 0;
  if (flag)
    cout << ((long long)(R - L + 1) * m % k
                 ? (long long)(R - L + 1) * m % k + ans
                 : 0)
         << "\n";
  else
    cout << ans + (long long)(R - L + 1) * m << "\n";
  return 0;
}
