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;
long long n, k, m, a[100005], sum[100005], b[100005], c[100005];
void brute() {
  int x[100005];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) x[(i - 1) * n + j] = a[j];
  int sz = m * n;
  while (1) {
    if (!sz) break;
    bool good = true;
    for (int i = 1; i <= sz; i++) {
      good = true;
      for (int j = i; j <= i + k - 1; j++) {
        if (x[i] != x[j] || j > sz) {
          good = false;
          break;
        }
      }
      if (good) {
        for (int j = i; j <= sz; j++) x[j] = x[j + k];
        sz -= k;
        break;
      }
    }
    if (!good) break;
  }
  cout << "brute " << sz << endl;
}
struct node {
  int val;
  node* prev;
  node* next;
};
int main() {
  bool used[100005];
  cin >> n >> k >> m;
  long long ans = m * n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  node* head = new node();
  head->val = a[1];
  head->prev = NULL;
  node* prev = head;
  for (int i = 2; i <= n; i++) {
    node* x = new node();
    x->val = a[i];
    prev->next = x;
    x->prev = prev;
    prev = x;
    if (i == n) x->next = NULL;
  }
  node* cur;
  node* last;
  node* q;
  while (1) {
    if (head == NULL) break;
    int tmp = k;
    cur = head;
    while (tmp && cur != NULL) {
      tmp--;
      cur = cur->next;
    }
    if (!tmp)
      last = cur;
    else
      break;
    cur = head;
    while (cur != last) {
      sum[cur->val]++;
      cur = cur->next;
    }
    cur = head;
    bool deleted = false;
    while (1) {
      if (sum[cur->val] == k) {
        sum[cur->val] = 0;
        deleted = true;
        if (cur->prev != NULL)
          cur->prev->next = last;
        else
          head = last;
        if (last != NULL) last->prev = cur->prev;
        break;
      }
      if (last == NULL) break;
      sum[cur->val]--;
      sum[last->val]++;
      cur = cur->next;
      last = last->next;
    }
    if (!deleted) break;
  }
  int sz = 0;
  while (head != NULL) {
    sz++;
    b[sz] = head->val;
    head = head->next;
  }
  ans -= ((long long)n - (long long)sz) * (long long)m;
  n = sz;
  if (m == 1) {
    cout << ans << endl;
    return 0;
  }
  if (!n) {
    cout << ans << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) c[i] = b[i];
  long long div = m / 2;
  long long mod = m % 2;
  long long sz_b = n, sz_c = n;
  long long ptr_b = n, ptr_c = 1;
  while (1) {
    bool good = 1;
    for (int i = 1; i <= ptr_b; i++)
      if (b[i] != b[1]) good = 0;
    for (int i = ptr_c; i <= sz_c; i++)
      if (c[i] != b[1]) good = 0;
    if (good) {
      ans = ((sz_b + sz_c) * div + sz_b * mod) % k;
      break;
    }
    int tmp = k, e = ptr_b, f = ptr_c;
    for (int i = ptr_b; i >= 1; i--) {
      if (b[i] != b[ptr_b] || !tmp) {
        e = i;
        break;
      }
      tmp--;
    }
    for (int i = ptr_c; i <= n; i++) {
      if (c[i] != b[ptr_b] || !tmp) {
        f = i;
        break;
      }
      tmp--;
    }
    if (tmp) break;
    ans -= ((m - 1) * (ptr_b - e) + (m - 1) * (f - ptr_c));
    ptr_b = e;
    ptr_c = f;
  }
  cout << ans << endl;
}
