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;
long long k;
long long m;
long long answer;
long long f(vector<int> &a) {
  vector<bool> del(a.size(), false);
  long long teamed = 0;
  bool t_last = true;
  while (t_last) {
    t_last = false;
    vector<int> eq(a.size(), 0);
    for (size_t i = 1; i < a.size(); ++i) {
      if (a[i] == a[i - 1]) {
        eq[i] = 1 + eq[i - 1];
      }
    }
    for (size_t i = 0; i < a.size(); ++i) {
      if (eq[i] == k - 1 && !del[i - k + 1]) {
        teamed++;
        t_last = true;
        for (long long j = 0; j < k; ++j) {
          del[i - j] = true;
        }
      }
    }
    vector<int> new_bus;
    for (size_t i = 0; i < a.size(); ++i) {
      if (!del[i]) {
        new_bus.push_back(a[i]);
      }
    }
    for (size_t i = 0; i < new_bus.size(); ++i) {
      del[i] = false;
    }
    a = new_bus;
  }
  return teamed;
}
int main(int argc, char *argv[]) {
  cin >> n;
  cin >> k;
  cin >> m;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  answer = n * m;
  long long x = f(a);
  while (x) {
    answer -= m * x * k;
    x = f(a);
  }
  vector<int> new_a;
  for (auto x : a) {
    new_a.push_back(x);
  }
  for (auto x : a) {
    new_a.push_back(x);
  }
  a = new_a;
  x = f(a);
  while (x) {
    answer -= (m - 1) * x * k;
    x = f(a);
  }
  if (a.empty()) {
    cout << 0 << endl;
    return 0;
  }
  if (!a.empty()) {
    bool all_are_the_same = true;
    for (size_t i = 1; i < a.size(); ++i) {
      if (a[0] != a[i]) {
        all_are_the_same = false;
      }
    }
    if (all_are_the_same) {
      cout << n % k << endl;
      return 0;
    }
  }
  cout << answer << endl;
  return 0;
}
