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 mx = 200010;
struct info {
  int a, num;
  info() {}
  info(int _1, int _2) {
    a = _1;
    num = _2;
  }
};
vector<info> Ori, Ans;
int n, k, m;
void reduce(vector<info> &X) {
  vector<info> tmp;
  tmp.clear();
  for (int i = 0; i < X.size(); i++)
    if (tmp.size() == 0 || tmp.back().a != X[i].a)
      tmp.push_back(X[i]);
    else {
      tmp.back().num = (tmp.back().num + X[i].num) % k;
      if (tmp.back().num == 0) tmp.pop_back();
    }
  X = tmp;
}
long long len(vector<info> &X) {
  long long ans = 0;
  for (int i = 0; i < X.size(); i++) ans += X[i].num;
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    Ori.push_back(info(x, 1));
  }
  reduce(Ori);
  if (Ori.size() == 1) {
    printf("%lld\n", (long long)Ori[0].num * m % k);
    return 0;
  }
  long long prelen = len(Ori), sz = Ori.size(), ori2 = Ori[sz / 2].num;
  for (int i = 0; i < sz; i++) Ori.push_back(Ori[i]);
  reduce(Ori);
  if (Ori.size() == 0) {
    if (m % 2 == 1)
      printf("%lld\n", prelen);
    else
      puts("0");
  } else if (Ori.size() == sz) {
    assert(sz % 2 == 1);
    if ((long long)ori2 * m % k == 0) {
      puts("0");
      return 0;
    } else {
      printf("%lld\n", prelen - ori2 + (long long)ori2 * m % k);
      return 0;
    }
  } else {
    long long delt = len(Ori) - prelen;
    printf("%lld\n", delt * (m - 1) + prelen);
  }
  return 0;
}
