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 MAXN = 1e5 + 100;
int n, k, m;
int a[MAXN];
pair<int, int> Stack[MAXN];
int cnt;
vector<int> now;
long long solve() {
  if (!now.size()) return 0;
  int bot = 0;
  int len = now.size();
  int di = 0;
  int res = 0;
  for (int i = 0; i < len; i++) {
    if (cnt == di) Stack[cnt++] = {now[i], 1};
    if (now[i] == Stack[cnt - 1].first)
      Stack[cnt++] = {now[i], Stack[cnt - 1].second + 1};
    else
      Stack[cnt++] = {now[i], 1};
    bot += 1;
    if (Stack[cnt - 1].second == k) {
      cnt -= k;
      len -= k - bot;
      di += bot;
      res += k;
      bot = 0;
    }
  }
  int _len = (cnt - di) / 2;
  int flag = Stack[di].first;
  if (_len <= 0) {
    return 0;
  }
  for (int i = di; i < di + _len; i++) {
    if (flag != Stack[i].first) {
      flag = 0;
      break;
    }
  }
  if (!flag) {
    return (long long)(cnt - di) / 2 * m + ((cnt - di) / 2 == 0 ? 0 : res);
  }
  if ((long long)_len * m % k == 0)
    return 0;
  else
    return (long long)_len * m % k + res;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (cnt == 0)
      Stack[cnt++] = {a[i], 1};
    else {
      if (a[i] == Stack[cnt - 1].first)
        Stack[cnt++] = {a[i], Stack[cnt - 1].second + 1};
      else
        Stack[cnt++] = {a[i], 1};
    }
    if (Stack[cnt - 1].second == k) {
      cnt -= k;
    }
  }
  if (m == 1) {
    printf("%d\n", cnt);
    return 0;
  }
  for (int i = 0; i < cnt; i++) now.push_back(Stack[i].first);
  printf("%lld\n", solve());
}
