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() {
  int r = cnt - 1, l = 0;
  int ans = 0;
  for (; r >= 0 && l < cnt && Stack[r].first == Stack[l].first;) {
    int num = 0;
    int tmpr = r, tmpl = l;
    while (tmpr >= 0 && Stack[tmpr].first == Stack[tmpl].first) tmpr--, num++;
    while (num < k && tmpl < cnt && tmpl <= tmpr &&
           Stack[tmpl].first == Stack[tmpr + 1].first)
      tmpl++, num++;
    if (num == k) {
      ans += k;
      r = tmpr;
      l = tmpl;
    } else {
      break;
    }
  }
  int flag = Stack[l].first;
  for (int i = l; i <= r; i++) {
    if (flag != Stack[i].first) {
      return (long long)ans + (long long)(r - l + 1) * m;
    }
  }
  long long tmp = (long long)(r - l + 1) * m % k;
  return tmp ? tmp + ans : 0;
}
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);
  cout << solve();
}
