#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
int main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
long long n, k, m;
vector<long long> a;
stack<pair<long long, long long> > st;
inline void solve() {
  for (long long i = 0; i < n; i++) {
    if (!st.empty() && st.top().first == a[i]) {
      long long z = st.top().second;
      st.pop();
      st.push({a[i], z + 1});
    } else {
      st.push({a[i], 1});
    }
    if (!st.empty() && st.top().second == k) {
      st.pop();
    }
  }
  deque<pair<long long, long long> > b;
  while (!st.empty()) {
    b.push_back(st.top());
    st.pop();
  }
  reverse((b).begin(), (b).end());
  long long r = (long long)((b).size());
  long long p = 0;
  for (long long i = 0; i < r; i++) {
    if (b[i].first == b[r - 1 - i].first &&
        b[i].second + b[r - 1 - i].second == k) {
      p = i + 1;
    } else {
      break;
    }
  }
  long long ans = 0;
  if (p == r) {
    if (m % 2 == 0) {
      ans = 0;
    } else {
      long long s = 0;
      for (long long i = 0; i < r; i++) {
        s += b[i].second;
      }
      ans = s;
    }
  } else if (p == r / 2 && r % 2 == 1) {
    long long fh = 0;
    for (long long i = 0; i < p; i++) {
      fh += b[i].second;
    }
    long long md = m * b[p].second;
    long long sh = 0;
    for (long long i = p + 1; i < r; i++) {
      sh += b[i].second;
    }
    if (md % k == 0) {
      ans = 0;
    } else {
      ans = fh + sh + md % k;
    }
  } else {
    long long s = 0;
    for (long long i = 0; i < r; i++) {
      s += b[i].second;
    }
    long long s_ = k * p;
    if (b[p].first == b[r - 1 - p].first) {
      s_ += (b[p].second + b[r - 1 - p].second) / k * k;
    }
    ans = s * m - s_ * (m - 1);
  }
  cout << ans << "\n";
}
inline void read() {
  cin >> n >> k >> m;
  a.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
}
