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;
int main() {
  long long int n, k, m;
  long long int count = 0;
  long long int team = 0;
  cin >> n >> k >> m;
  vector<long long int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  stack<long long int> S;
  S.push(A[0]);
  int i = 1;
  long long int round_ = 0;
  if (i == n) {
    if (round_ != m) {
      round_++;
      i = 0;
    }
  }
  if (n == 1) {
    cout << m % k << endl;
    return 0;
  }
  while ((round_ != m)) {
    count = -1;
    while ((!S.empty()) && (i != n) && (round_ != m) && (count != k) &&
           (S.top() == A[i])) {
      if (count == -1) count = 1;
      S.push(A[i]);
      count++;
      i++;
      if (i == n) {
        round_++;
        i = 0;
      }
      if (count == k) {
        while (count != 0) {
          S.pop();
          count--;
        }
        count = -1;
        team++;
      }
    }
    if ((i != n) && (round_ != m)) {
      S.push(A[i]);
      i++;
    }
    if (i == n) {
      if (round_ != m) {
        round_++;
        i = 0;
      }
    }
  }
  stack<long long int> S2;
  count = 0;
  long long int xcc = 0;
  long long int x = -1;
  bool flag = true;
  team = 0;
  if (!S.empty()) {
    x = S.top();
    xcc = 1;
  }
  while (!S.empty()) {
    S.pop();
    if (!S.empty()) {
      if (x == S.top()) {
        xcc++;
      } else {
        x = S.top();
        xcc = 0;
      }
    }
    if ((flag) && (xcc == k)) {
      team++;
      xcc = 0;
    }
    count++;
  }
  cout << count - team * k << endl;
  return 0;
}
