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, k, m;
vector<pair<int, int> > v, u;
int a, b, c;
int main() {
  cin >> n >> k >> m;
  a = n;
  for (int i = 0; i < n; i++) {
    int w;
    cin >> w;
    if (v.size() > 0 && v.back().first == w) {
      v.back().second++;
      if (v.back().second == k) {
        v.pop_back();
        a -= k;
      }
    } else
      v.push_back({w, 1});
  }
  u = v;
  int b = a;
  int x = 0, y = u.size() - 1;
  while (x < y) {
    if (u[x].first == u[y].first) {
      if (u[x].second + u[y].second == k) {
        x++;
        y--;
        b -= k;
      } else {
        if (u[x].second + u[y].second > k) b -= k;
        break;
      }
    } else {
      break;
    }
  }
  long long r = m * b;
  a -= b;
  if (x == y) {
    r = r % k;
    if (r == 0) a = 0;
  }
  cout << a + r << endl;
  return 0;
}
