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 INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 1e5 + 5;
long long n, k, m, a[N];
vector<int> v;
vector<int> conc(vector<int> v) {
  vector<int> ret;
  for (auto it : v) ret.push_back(it);
  for (auto it : v) ret.push_back(it);
  return ret;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int at = 0;
  long long res = n;
  for (int i = 0; i < n; i++) {
    if (a[i] != a[at]) {
      while (at < i) {
        v.push_back(a[at++]);
        res--;
      }
    } else {
      if (i - at + 1 == k) at = i + 1;
    }
  }
  while (at < n) {
    v.push_back(a[at++]);
    res--;
  }
  res *= m;
  int l = v.size() - 1;
  int r = 0;
  while (1) {
    long long ct = 0;
    int at;
    int ra = r, la = l;
    at = l;
    while (l >= r and v[l] == v[at]) {
      ct++;
      l--;
    }
    at = r;
    while (r < l and v[r] == v[at]) {
      r++;
      ct++;
      if (ct == k) {
        res += (m - 1) * ct;
        break;
      }
    }
    if (ct < k) {
      r = ra;
      l = la;
      break;
    }
  }
  bool f = true;
  for (int i = r; i <= l; i++) {
    if (v[i] != v[r]) f = false;
  }
  if (f) {
    long long val = (l - r + 1LL) * m;
    res += (val - val % k);
    int il = r - 1, ir = l + 1;
    while (val >= k and !(val % k) and il <= ir) {
      int at;
      val = 0;
      at = il;
      for (; il >= 0 and v[il] == v[at]; il--) val++;
      at = ir;
      for (; ir < (int)v.size() and v[ir] == v[at]; ir++) val++;
      if (val >= k) res += k;
    }
  }
  cout << n * m - res << endl;
  return 0;
}
