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;
int stk[100005][2];
int bak[100005][2];
vector<pair<int, int> > v;
int top = 0;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (!top || stk[top][0] != x) {
      stk[++top][0] = x;
      stk[top][1] = 1;
    } else {
      stk[top][1]++;
    }
    if (stk[top][1] == k) stk[top--][1] -= k;
  }
  long long tot = 0;
  for (int i = 1; i <= top; i++) {
    tot += stk[i][1];
  }
  int b = 1, e = top;
  while (b < e && stk[b][0] == stk[e][0]) {
    if ((stk[e][1] + stk[b][1]) % k == 0) {
      e--;
      b++;
    } else {
      stk[b][1] = (stk[b][1] + stk[e][1]) % k;
      stk[e][1] = 0;
      break;
    }
  }
  long long ans = 0;
  if (e > b) {
    for (int i = b; i <= e; i++) ans += stk[i][1];
    ans *= (m - 1);
    ans += tot;
  } else if (e == b) {
    if (stk[b][1] * m % k == 0)
      ans = 0;
    else {
      ans = tot + stk[b][1] * (m - 1);
      ans -= stk[b][1] * m - stk[b][1] * m % k;
    }
  }
  cout << ans << endl;
}
