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 MOD = 1e9 + 7;
bool debug = 0;
int main() {
  long long n, k, m;
  scanf("%lld%lld%lld", &n, &k, &m);
  long long tot = n * m;
  vector<int> v;
  list<int> l;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    l.push_back(x);
  }
  long long sairam = 0;
  int ant = -1;
  int streak = 0;
  for (auto it = l.begin(); it != l.end();) {
    if (*it == ant) {
      streak++;
      if (streak >= k) {
        sairam += k;
        while (streak--) {
          it = l.erase(it);
          if (it != l.begin()) it--;
        }
        ant = -1;
      }
      it++;
    } else {
      streak = 1;
      ant = *it;
      it++;
    }
  }
  for (auto it : l) {
    v.push_back(it);
  }
  sairam *= m;
  n = v.size();
  if (!n) {
    cout << 0 << endl;
    return 0;
  }
  int idi = 0, idf = n - 1;
  streak = 0;
  if (v[idi] != v[idf]) {
    cout << 1ll * n * m << endl;
    return 0;
  }
  int pidi = 0, pidf = n - 1;
  while (idi < idf and idi + 1 != idf) {
    if (streak == 0) {
      if (v[idi] == v[idf]) {
        streak = 2;
        continue;
      } else
        break;
    }
    if (streak == k) {
      idi++;
      idf--;
      pidi = idi, pidf = idf;
      streak = 0;
      continue;
    }
    if (v[idi + 1] == v[idf]) {
      streak++;
      idi++;
    } else if (v[idi] == v[idf - 1]) {
      streak++;
      idf--;
    } else {
      break;
    }
  }
  idi = pidi, idf = pidf;
  if (debug)
    cout << "idi"
         << " = " << (idi) << endl;
  if (debug)
    cout << "idf"
         << " = " << (idf) << endl;
  if (debug)
    cout << "n"
         << " = " << (n) << endl;
  if (idf < idi) {
    cout << 0 << endl;
    return 0;
  }
  bool ig = 1;
  ant = v[idi];
  for (int i = idi + 1; i <= idf; i++) {
    if (v[i] != ant) ig = 0;
  }
  long long tc = 1ll * (idf - idi + 1) * m;
  if (!ig) {
    if (debug) cout << ("aqui") << endl;
    ;
    cout << n - (idf - idi + 1) + tc << endl;
    return 0;
  }
  tc = tc % k;
  if (!tc) {
    if (debug) cout << ("!tc") << endl;
    ;
    cout << 0 << endl;
  } else {
    if (debug) cout << ("ult") << endl;
    ;
    cout << n - (idf - idi + 1) + tc << endl;
  }
  return 0;
}
