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;
long long n, k, m, a[100005];
vector<pair<long long, long long> > st;
void brute() {
  int x[100005];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) x[(i - 1) * n + j] = a[j];
  int sz = m * n;
  while (1) {
    if (!sz) break;
    bool good = true;
    for (int i = 1; i <= sz; i++) {
      good = true;
      for (int j = i; j <= i + k - 1; j++) {
        if (x[i] != x[j] || j > sz) {
          good = false;
          break;
        }
      }
      if (good) {
        for (int j = i; j <= sz; j++) x[j] = x[j + k];
        sz -= k;
        break;
      }
    }
    if (!good) break;
  }
  cout << "brute " << sz << endl;
}
int main() {
  cin >> n >> k >> m;
  long long ans = m * n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (st.empty())
      st.push_back({a[i], 1});
    else {
      if (st[st.size() - 1].first == a[i])
        st[st.size() - 1].second++;
      else
        st.push_back({a[i], 1});
    }
    if (st[st.size() - 1].second == k) {
      st.pop_back();
      ans -= k * m;
    }
  }
  if (st.empty()) {
    cout << ans << endl;
    return 0;
  }
  long long idx = -1;
  for (int i = 0; i < st.size(); i++) {
    int x = i, y = st.size() - 1 - i;
    if (st[x].first != st[y].first || st[x].second + st[y].second != k) {
      idx = i;
      break;
    }
  }
  if (idx == -1) {
    if (m % 2) {
      long long sum = 0;
      for (int i = 0; i < st.size(); i++) sum += st[i].second;
      cout << sum << endl;
    } else
      puts("0");
    return 0;
  }
  ans -= (m - 1) * k * idx;
  vector<pair<int, int> > v;
  for (int i = idx; i < st.size() - idx; i++) {
    v.push_back(st[i]);
  }
  if (v.size() == 1) {
    ans -= (long long)v[0].second * m / k * k;
    for (int i = idx - 1; i >= 0; i--) {
      if ((long long)v[0].second * m % k != 0) break;
      if (st[i].first != st[st.size() - 1 - i].first ||
          st[i].second + st[st.size() - 1 - i].second != k)
        break;
      ans -= k;
    }
    cout << ans << endl;
    return 0;
  }
  int last_idx = v.size() - 1;
  if (v[0].first != v[last_idx].first || v[0].second + v[last_idx].second < k) {
    cout << ans << endl;
    return 0;
  }
  long long red = v[0].second + v[last_idx].second;
  red = (red / k) * k;
  ans -= red * (m - 1);
  cout << ans << endl;
}
