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;
const long long MOD = 1e9 + 7, LINF = 1e18 + 1e16;
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const int N = 1e5 + 1;
class TaskB {
  int n, k, m, a[N];
  deque<pair<int, int> > q;
  long long ans;

 public:
  void solve(istream& cin, ostream& cout) {
    cin >> n >> k >> m;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (!q.empty() && q.front().first == a[i])
        ++q.front().second;
      else
        q.emplace_front(a[i], 1);
      if (!q.empty() && q.front().second == k) q.pop_front();
    }
    long long sum = 0;
    for (auto p : q) sum += p.second;
    ans = 1ll * m * sum;
    if (m == 1) {
      cout << ans << endl;
      return;
    }
    int residue = 0;
    while (q.size() >= 2 && q.front().first == q.back().first &&
           q.front().second + q.back().second >= k) {
      ans -= 1ll * (m - 1) * k;
      if (q.front().second + q.back().second > k) break;
      q.pop_front();
      q.pop_back();
      residue += k;
    }
    if (q.size() == 1) {
      ans = 1ll * q.front().second * m % k;
      if (ans) ans += residue;
    }
    cout << ans << endl;
  }
};
class Solver {
 public:
  void solve(std::istream& in, std::ostream& out) {
    TaskB* obj = new TaskB();
    obj->solve(in, out);
    delete obj;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solver solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
