#include <bits/stdc++.h>
using namespace std;
const int qq = 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
long long n, k, m;
pair<long long, long long> p[qq];
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  int pre = -1;
  int top = 0, cnt = 0;
  p[0].first = -1;
  for (int x, i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (!top || p[top].first != x) {
      p[++top].first = x;
      p[top].second = 1;
    } else {
      p[top].second++;
    }
    if (p[top].second == k) {
      p[top--].second -= k;
    }
  }
  long long sum = 0;
  for (int i = 1; i <= top; ++i) {
    sum += p[i].second;
  }
  if (top == 0) {
    printf("0\n");
    return 0;
  }
  if (m == 1) {
    printf("%d\n", sum);
  } else if (k >= n) {
    if (top == 1) {
      printf("%lld\n", sum * m % k);
    } else {
      printf("%lld\n", sum * m);
    }
  } else if (k < n) {
    if (top == 1) {
      printf("%lld\n", sum * m % k);
    } else {
      int l = 1, r = top;
      long long d = 0, tmp = 0;
      while (l < r) {
        if (p[l].first != p[r].first) break;
        if ((p[l].second + p[r].second) % k == 0) {
          d += p[l].second + p[r].second;
          l++, r--;
        } else {
          p[l].second = (p[l].second + p[r].second) % k;
          p[r].second = 0;
          break;
        }
      }
      long long ans = 0;
      if (l < r) {
        for (int i = l; i <= r; ++i) {
          ans += p[i].second;
        }
        ans *= (m - 1);
        ans += sum;
      } else if (l == r) {
        if (p[l].second * m % k == 0) {
          ans = 0;
        } else {
          ans = sum + p[l].second * (m - 1);
          ans -= p[l].second * m - p[l].second * m % k;
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
