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 int mo = 1000000007;
inline void gn(long long &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
inline void gn(long double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
template <class T1, class T2>
inline void gn(T1 &r, T2 &s) {
  gn(r), gn(s);
}
template <class T1, class T2, class T3>
inline void gn(T1 &r, T2 &s, T3 &t) {
  gn(r), gn(s), gn(t);
}
template <class T1, class T2, class T3, class T4>
inline void gn(T1 &r, T2 &s, T3 &t, T4 &u) {
  gn(r), gn(s), gn(t), gn(u);
}
inline void gs(char *s) { scanf("%s", s); }
inline void gc(char &c) {
  while ((c = getchar()) > 126 || c < 33)
    ;
}
inline void pc(char c) { putchar(c); }
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long powmod(long long a, long long b, long long mo) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 111111, M = 111111;
int l, m, n, t, C;
set<int> S;
int a[N], b[N];
int main() {
  scanf("%d%d%d", &n, &t, &m);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  int nn = n, sum = 0;
  n = 0;
  for (int i = (1); i <= (nn); ++i) {
    if (n && a[i] == a[n])
      ++sum;
    else
      sum = 0;
    a[++n] = a[i];
    if (sum == t) {
      sum = 0;
      n -= t;
    }
  }
  int l = 1, r = n;
  while (1) {
    int long long = l, rr = r;
    while (a[long long] == a[l] && long long < rr) ++long long;
    while (a[rr] == a[r] && long long < rr) --rr;
    if (l == long long &&r == rr) break;
    while (long long - l + r - rr >= t) {
      int p = min(long long - l, t);
      l += p;
      r -= t - p;
    }
    if (l == long long &&r == rr)
      ;
    else
      break;
  }
  for (int i = (l); i <= (r); ++i) S.insert(a[i]);
  if (((int)(S).size()) == 1) {
    if (1ll * (r - l + 1) * m % t != 0)
      printf("%lld\n", 1ll * (r - l + 1) * m % t + l - 1 + (n - r));
    else {
      int sum = 0, top = 0;
      for (int i = (1); i <= (l - 1); ++i) {
        if (top && a[i] == b[top])
          ++sum;
        else
          sum = 1;
        b[++top] = a[i];
        if (sum == t) {
          sum = 0;
          top -= t;
        }
      }
      for (int i = (r + 1); i <= (n); ++i) {
        if (top && a[i] == b[top])
          ++sum;
        else
          sum = 1;
        b[++top] = a[i];
        if (sum == t) {
          sum = 0;
          top -= t;
        }
      }
      printf("%d\n", top);
    }
  } else {
    printf("%lld\n", n + 1ll * (m - 1) * (r - l + 1));
  }
  return 0;
}
