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 maxn = 1e5 + 1;
int n, k, m, a[maxn], Next[maxn], sz = 0;
deque<pair<int, int> > de;
void OpenFile() {
  freopen(
      ""
      ".INP",
      "r", stdin);
  freopen(
      ""
      ".OUT",
      "w", stdout);
}
void Enter() {
  cin >> n >> k >> m;
  Next[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    Next[i] = i + 1;
  }
}
void Init() {
  int pre = 0;
  for (int i = Next[0]; i <= n; i = Next[i]) {
    int j, second = 0;
    for (j = i; j <= n && second < k && a[i] == a[j]; j = Next[j]) ++second;
    if (second == k) {
      Next[pre] = j;
      i = pre;
    } else
      pre = i;
  }
  pre = 0;
  for (int i = Next[0]; i <= n; i = Next[i]) {
    if (a[i] == pre)
      ++de.back().second;
    else {
      de.push_back(pair<int, int>(a[i], 1));
      pre = a[i];
    }
  }
}
void Solve() {
  while (de.size() > 1) {
    if (de.front().first == de.back().first)
      if (de.front().second + de.back().second == k) {
        de.pop_front();
        de.pop_back();
        sz += k;
      } else {
        de.back().second += de.front().second;
        de.pop_front();
        if (de.back().second > k) de.back().second -= k;
        break;
      }
    else
      break;
  }
  if (de.size() == 0)
    cout << 0;
  else if (de.size() == 1)
    if (1ll * de.back().second * m % k == 0)
      cout << sz % k;
    else
      cout << 1ll * de.back().second * m % k + sz;
  else {
    int sz2 = 0;
    while (!de.empty()) sz2 += de.back().second, de.pop_back();
    cout << 1ll * sz2 * m + sz;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Enter();
  Init();
  Solve();
}
