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;
int n, i, j, k, x, y, z, m, q, h, r, timer, mx, l;
int a[100500];
vector<int> f, g;
long long solve() {
  int lst = 0, cnt = 0;
  f.clear();
  g.clear();
  for (int i = 0; i < n; i++) {
    if (f.empty()) {
      f.push_back(a[i]);
      lst = a[i];
      cnt = 1;
    } else {
      if (a[i] == f.back()) {
        cnt++;
        f.push_back(a[i]);
      } else {
        cnt = 1;
        f.push_back(a[i]);
      }
      if (cnt == k) {
        for (int j = 0; j < k; j++) f.pop_back();
        if (!f.empty()) {
          int idx = f.size();
          idx--;
          lst = f[idx];
          idx--;
          cnt = 1;
          while (idx >= 0 && lst == f[idx]) cnt++, idx--;
        }
      }
    }
  }
  int sz = f.size();
  if (sz == 0) {
    return 0;
  }
  for (int i = 0; i < sz; i++) g.push_back(f[i]);
  for (int i = 0; i < sz; i++) {
    if (f.empty()) {
      f.push_back(g[i]);
      lst = a[i];
      cnt = 1;
    } else {
      if (g[i] == f.back()) {
        cnt++;
        f.push_back(g[i]);
      } else {
        cnt = 1;
        f.push_back(g[i]);
      }
      if (cnt == k) {
        for (int j = 0; j < k; j++) f.pop_back();
        if (!f.empty()) {
          int idx = f.size();
          idx--;
          lst = f[idx];
          idx--;
          cnt = 1;
          while (idx >= 0 && lst == f[idx]) cnt++, idx--;
        }
      }
    }
  }
  int newsz = f.size();
  if (newsz == 0) {
    if (m % 2 == 0) {
      return 0;
    } else {
      return sz;
    }
  }
  int mag = (2 * sz - newsz) / 2;
  bool flag = true;
  for (int i = mag; i < sz - mag - 1; i++)
    if (g[i] != g[i + 1]) flag = false;
  if (!flag) {
    return (1LL * sz * m - 2LL * mag * (m - 1));
  }
  long long val = 1LL * m * (2 * sz - 2 * mag);
  long long ans = 1LL * sz * m - 2LL * mag * (m - 1);
  if (val % k != 0) {
    ans -= (val - val % k);
    return ans;
  } else {
    return 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  bool flag = true;
  for (int i = 0; i + 1 < n; i++)
    if (a[i] != a[i + 1]) flag = false;
  if (flag) {
    cout << 1LL * n * m % k << endl;
    return 0;
  }
  cout << solve() << endl;
  return 0;
}
