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 a[maxn];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  vector<pair<int, int> > st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  st.push_back({a[0], 1});
  for (int i = 1; i < n; i++) {
    if (st.empty() || st[st.size() - 1].first != a[i])
      st.push_back({a[i], 1});
    else {
      st[st.size() - 1].second++;
      if (st[st.size() - 1].second == k) st.pop_back();
    }
  }
  int N = 0;
  n = st.size();
  for (int i = 0; i < n; i++) N += st[i].second;
  int l1 = 0, r1 = n - 1;
  int numd = 0;
  while (true) {
    if (st[l1].first != st[r1].first) break;
    if (l1 == r1) break;
    int ns = st[l1].second + st[r1].second;
    numd += (ns / k) * k;
    if (ns % k != 0) break;
    l1++, r1--;
  }
  if (l1 == r1) {
    cout << (st[l1].second * m) % k;
    return 0;
  }
  cout << N * m - (m - 1) * numd;
}
