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 result = 0;
deque<pair<int, int>> solve(vector<int> a, int m, int k) {
  deque<pair<int, int>> result;
  for (auto& item : a) {
    if (!result.empty() && result.back().first == item) {
      ++result.back().second;
    } else {
      result.emplace_back(item, 1);
    }
    if (result.back().second == k) {
      ::result -= 1LL * m * k;
      result.pop_back();
    }
  }
  return result;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  result = 1LL * n * m;
  vector<int> a(n);
  for (auto& item : a) {
    cin >> item;
  }
  if (m == 2) {
    for (int i = 0; i < n; ++i) {
      a.push_back(a[i]);
    }
    m = 1;
  }
  if (m == 1) {
    solve(a, m, k);
    cout << result << '\n';
    return 0;
  }
  auto d = solve(a, m, k);
  if (d.empty()) {
    cout << result << '\n';
    return 0;
  }
  auto lf = d, rt = d;
  while (((int)d.size()) > 1) {
    if (d.front().first != d.back().first) {
      cout << result << '\n';
      return 0;
    }
    int total = d.front().second + d.back().second;
    result -= 1LL * (m - 1) * (total / k) * k;
    if (total % k) {
      cout << result << '\n';
      return 0;
    }
    d.pop_front();
    d.pop_back();
    lf.pop_back();
    rt.pop_front();
  }
  result -= (1LL * m * d.back().second / k) * k;
  int val = 1LL * m * d.back().second % k;
  lf.pop_back();
  rt.pop_front();
  if (val > 0) lf.emplace_back(d.back().first, val);
  lf.insert(lf.end(), rt.begin(), rt.end());
  vector<int> b;
  for (auto& item : lf) {
    while (item.second > 0) {
      b.push_back(item.first);
      --item.second;
    }
  }
  solve(b, 1, k);
  cout << result << '\n';
  return 0;
}
