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;
const int N = 1e6 + 10;
vector<pair<int, int> > v;
int a[N];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int w = a[0];
  int count = 1;
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    if (w != a[i]) {
      count %= k;
      if (count != 0) {
        v.push_back({w, count});
      }
      w = a[i];
      count = 1;
    } else
      count++;
  }
  if (count % k) v.push_back({w, count % k});
  if (k >= n) {
    int flag = 0;
    for (int i = 1; i < v.size() - 1; i++) {
      if (v[i] != v[i - 1]) flag = 1;
    }
    if (!flag)
      cout << 1ll * n * m % k;
    else
      cout << 1ll * n * m << endl;
    return 0;
  }
  for (auto &[x, y] : v) {
    sum += y;
  }
  if (m == 1 || sum == 0) {
    cout << sum << endl;
    return 0;
  }
  sum *= 1ll * m;
  int len = v.size();
  int l = 0, r = len - 1;
  while (l < r) {
    if (v[l].first != v[r].first) {
      cout << sum << endl;
      return 0;
    }
    if ((v[l].second + v[r].second) == k) {
      l++, r--;
      sum = sum - 1ll * (m - 1) * k;
      continue;
    }
    if ((v[l].second + v[r].second) > k) {
      sum = sum - 1ll * (m - 1) * k;
      cout << sum << endl;
      return 0;
    }
  }
  if (l > r) {
    cout << 0 << endl;
    return 0;
  }
  if (l == r) {
    long long acg = 1ll * v[l].second * m;
    if (acg % k == 0)
      sum = 0;
    else
      sum -= acg / (long long)k * (long long)k;
  }
  cout << sum << endl;
  return 0;
}
