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 N = 1e5 + 5;
int n, k, m;
int a[N];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int num = 0;
  int prev = a[1];
  vector<int> v, g;
  int tmp = n;
  a[n + 1] = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == prev) {
      num++;
    } else {
      tmp -= (num - (num % k));
      num %= k;
      if (num) {
        v.push_back(num);
        g.push_back(prev);
        num = 1;
      } else {
        int siz = v.size();
        if (siz == 0) {
          num = 1;
        } else {
          if (g[siz - 1] == a[i]) {
            num = v[siz - 1] + 1;
            v.pop_back();
            g.pop_back();
          } else {
            num = 1;
          }
        }
      }
      prev = a[i];
    }
  }
  n = tmp;
  if (n == 0) {
    printf("%d\n", 0);
    return 0;
  }
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  num = v.size();
  if (g[0] != g[num - 1]) {
    long long x = 1ll * n * m;
    printf("%lld\n", x);
    return 0;
  }
  int l = 0, r = num - 1;
  long long x = 1ll * n * m;
  while (l < r and g[l] == g[r]) {
    long long y = v[l] + v[r];
    if (y % k == 0) {
      x -= 1ll * (m - 1) * y;
      l++;
      r--;
    } else {
      y -= y % k;
      x -= 1ll * (m - 1) * y;
      printf("%lld\n", x);
      return 0;
    }
  }
  if (l == r) {
    long long y = 1ll * m * v[l];
    x -= (y - (y % k));
    if ((y % k) == 0) {
      r--;
      while (r >= 0) {
        y = 2 * v[r];
        x -= (y - (y % k));
        if ((y % k) > 0) break;
        r--;
      }
      printf("%lld\n", x);
      return 0;
    } else {
      printf("%lld\n", x);
      return 0;
    }
  } else {
    printf("%lld\n", x);
    return 0;
  }
}
