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;
using ll = long long;
using P = pair<int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, m;
  cin >> n >> k >> m;
  deque<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  deque<P> aa;
  int cnt = 0, cur = a[0], hoge = 0;
  for (int i = 0; i < n; i++) {
    if (cur == a[i]) {
      cnt++;
      if (cnt == k) {
        cnt = 0;
        hoge++;
      }
    } else {
      if (cnt > 0) {
        aa.emplace_back(cur, cnt);
        cnt = 1;
        cur = a[i];
      }
    }
  }
  if (cnt > 0) {
    aa.emplace_back(cur, cnt);
  }
  deque<P> b(aa);
  int hoge2 = 0;
  for (P& p : aa) {
    if (b.empty()) {
      b.push_back(p);
    } else if (b.back().first == p.first) {
      b.back().second += p.second;
      hoge2 += b.back().second / k;
      b.back().second %= k;
      if (b.back().second == 0) b.pop_back();
    } else {
      b.push_back(p);
    }
  }
  if (b.empty()) {
    if (m % 2 == 0) {
      cout << 0 << endl;
    } else {
      int ans = 0;
      for (P& p : aa) {
        ans += p.second;
      }
      cout << ans << endl;
    }
    return 0;
  } else if (b.size() == 1) {
    ll fa = (ll)b[0].second * (m / 2) % k;
    if (m % 2 == 1) {
      if (aa[0].first == b[0].first) {
        fa += aa[0].second;
        fa %= k;
        aa[0].second = 0;
      }
      ll ans = fa;
      for (P& p : aa) {
        ans += p.second;
      }
      cout << ans << endl;
    } else {
      cout << fa << endl;
    }
  } else {
    ll ans = (ll)n * m - (ll)hoge * k * m - (ll)hoge2 * k * (m - 1);
    cout << ans << endl;
  }
  return 0;
}
