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 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 (pre == -1) {
      pre = x;
      cnt = 1;
    } else if (pre == x) {
      cnt++;
    } else {
      if (cnt % k != 0) {
        if (p[top].first == pre) {
          p[top].second = (p[top].second + cnt) % k;
          if (p[top].second == 0) {
            top--;
          }
        } else {
          ++top;
          p[top].first = pre;
          p[top].second = cnt;
        }
      }
      pre = x, cnt = 1;
    }
  }
  if (cnt % k != 0) {
    if (p[top].first == pre) {
      p[top].second = (p[top].second + cnt) % k;
      if (p[top].second == 0) top--;
    } else {
      ++top;
      p[top].first = pre;
      p[top].second = cnt;
    }
  }
  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 {
          tmp = (p[l].second + p[r].second) % k;
          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;
}
