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>
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long long LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const double pi = acos(-1.0);
using namespace std;
inline void debug(char ch) {
  for (int __ii = 0; __ii < 20; ++__ii) putchar(ch);
  printf("\n");
}
const double eps = 1e-8;
inline int dcmp(double a, double b) {
  if (fabs(a - b) < eps) return 0;
  return a < b ? -1 : 1;
}
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int maxn = 1e6 + 10;
long long a[maxn];
struct Node {
  long long x;
  long long cnt;
} p[maxn];
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  int flag = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%I64d", &a[i]);
    if (a[i] != a[0]) flag = 0;
  }
  int t = 1, tot = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1]) {
      t++;
    } else {
      p[tot].x = a[i];
      p[tot++].cnt = t;
      t = 1;
    }
  }
  p[tot].x = a[n - 1];
  p[tot++].cnt = t;
  long long ans = 0;
  for (int i = 0; i < tot; ++i) {
    if (p[i].cnt >= k) {
      ans += p[i].cnt / k * k;
      p[i].cnt = p[i].cnt % k;
    }
  }
  int l = 0, r = tot - 1;
  int num = 0;
  int hui = 1;
  while (l <= r) {
    if (p[l].x == p[r].x && (p[l].cnt + p[r].cnt) % k == 0)
      ;
    else {
      hui = 0;
      break;
    }
    l++, r--;
  }
  l = 0, r = tot - 1;
  while (l <= r) {
    if (p[l].x == p[r].x && p[l].cnt + p[r].cnt >= k) {
      num += (p[l].cnt + p[r].cnt) / k * k;
    } else
      break;
    if ((p[l].cnt + p[r].cnt) % k != 0) break;
    l++, r--;
  }
  if (hui)
    printf("0\n");
  else if (flag)
    printf("%I64d\n", (long long)n * m - (long long)n * m / k * k);
  else
    printf("%I64d\n", (long long)n * m - (long long)num * (m - 1) - ans);
}
