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>
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, m, k, top, a[100005];
pair<long long, long long> s[100005];
signed main() {
  n = read(), k = read(), m = read();
  for (register long long i = (1); i <= (n); ++i) {
    a[i] = read();
    if (s[top].first != a[i])
      s[++top] = make_pair(a[i], 1);
    else {
      s[top].second++;
      if (s[top].second == k) --top;
    }
  }
  long long r1 = 0, r2 = 0, res = 0;
  for (register long long i = (1); i <= (top); ++i) r1 += s[i].second;
  long long l = 1, r = top;
  while (l < r && s[l].first == s[r].first &&
         (s[l].second + s[r].second) % k == 0)
    r2 += s[l].second + s[r].second, ++l, --r;
  if (l == r) {
    if (s[l].second * m % k == 0) res -= r2;
    res += m * r1 - (m - 1) * r2 - (s[l].second * m / k * k);
    cout << res;
  } else {
    if (s[l].first == s[r].first) r2 += (s[l].second + s[r].second) / k * k;
    cout << m * r1 - (m - 1) * r2;
  }
  return 0;
}
