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;
int n, k, m;
const int maxN = (int)1e5 + 10;
int a[maxN];
int w[maxN];
int tp[maxN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(239);
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int sz = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      if (sz != 0) {
        w[sz] %= k;
        if (w[sz] == 0) sz--;
      }
      sz++;
      w[sz] = 1;
      tp[sz] = a[i];
    } else {
      w[sz]++;
    }
  }
  if (sz == 0) {
    cout << 0;
    return 0;
  }
  if (sz == 1) {
    cout << (1LL * m * w[1]) % k;
    return 0;
  }
  long long sum = 0;
  for (int i = 1; i <= sz; i++) {
    sum += w[i];
  }
  if (m == 1) {
    cout << sum;
    return 0;
  }
  int l = 1;
  int r = sz;
  while (true) {
    if (l == r) {
      long long num = 1LL * w[l] * m;
      if (num % k == 0) {
        cout << 0;
      } else {
        cout << num % k + (sum - w[l]);
      }
      return 0;
    }
    if (tp[l] != tp[r]) {
      long long sum_without = 0;
      long long sum_in = 0;
      for (int i = 1; i <= sz; i++) {
        if (i < l || i > r)
          sum_without += w[i];
        else
          sum_in += w[i];
      }
      cout << m * sum_in + sum_without;
      return 0;
    } else if (l + 1 == r) {
      long long num = m * (w[l] + w[r]);
      if (num % k != 0) {
        cout << (sum - w[l] - w[r]) + num % k;
      } else {
        cout << 0;
      }
      return 0;
    } else {
      long long num = w[l] + w[r];
      if (num % k != 0) {
        long long sum_without = 0;
        long long sum_in = 0;
        for (int i = 1; i <= sz; i++) {
          if (i < l || i > r)
            sum_without += w[i];
          else if (i > l && i < r)
            sum_in += w[i];
        }
        cout << sum_without + m * sum_in + (m - 1) * (num % k) + (w[l] + w[r]);
        return 0;
      } else {
        l++;
        r--;
      }
    }
  }
  return 0;
}
