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 n, k, m, num, answer;
bool checker;
int deeper(int start, int end, vector<int> test) {
  if (end - start + 1 == 1) {
    return ((end - start + 1) * m) % k;
  }
  if (end - start + 1 <= k) {
    checker = false;
    for (int i = start + 1; i <= end; i++) {
      if (test[i] == test[start]) checker = true;
    }
    if (checker == true) {
      return ((end - start + 1) * m) % k;
    } else {
      return (end - start + 1) * m;
    }
  }
  for (int j = start + k - 2; j >= 0; j--) {
    checker = false;
    int i = 1, p;
    for (; i < k; i++) {
      p = j - i;
      if (p < start) p = end + 1 + p - start;
      if (test[j] == test[p]) {
        checker = true;
      } else {
        checker = false;
        break;
      }
    }
    if (checker == true) {
      return (k + deeper(j + 1, p - 1, test) == k)
                 ? 0
                 : k + deeper(j + 1, p - 1, test);
    }
  }
  return (end - start + 1) * k;
}
int main() {
  cin >> n;
  cin >> k;
  cin >> m;
  vector<int> test(n);
  for (int i = 0; i < n; i++) {
    cin >> num;
    test[i] = num;
  }
  for (int i = 0; i < test.size(); i++) {
  }
  for (int it = 0; it < test.size(); ++it) {
    checker = false;
    if ((it + k - 1) >= test.size()) break;
    for (int j = 1; j < k; j++) {
      if (test[it] == test[it + j])
        checker = true;
      else {
        checker = false;
        break;
      }
    }
    if (checker == true) {
      test.erase(test.begin() + it, test.begin() + it + k);
      it--;
      if (it >= 0) it--;
    }
  }
  for (int i = 0; i < test.size(); i++) {
  }
  if (test.size() == 0) {
    cout << endl << "0";
    return 0;
  }
  answer = deeper(0, test.size() - 1, test);
  cout << endl << answer;
  return 0;
}
