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;
int a[100000];
int d[100000];
vector<pair<int, int> > v;
vector<pair<int, int> > v2;
void read_data() {
  cin >> n >> k >> m;
  int d, c;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0) {
      d = 1;
      c = a[i];
    } else if (c == a[i]) {
      d++;
    } else {
      v.push_back(make_pair(d, c));
      d = 1;
      c = a[i];
    }
  }
  v.push_back(make_pair(d, c));
}
void merge_two_bus() {
  int removed = 0;
  for (int i = 0; i < v.size(); i++) {
    pair<int, int> di = v[i];
    pair<int, int> back;
    if (!v2.empty()) {
      back = v2.back();
      if (back.second == di.second) {
        v2.pop_back();
        di.first += back.first;
      }
    }
    int t = di.first % k;
    removed += di.first - t;
    if (t != 0) v2.push_back(make_pair(t, di.second));
  }
  int removed2 = 0;
  int i;
  for (i = 0; i < (v2.size() + 1) / 2; i++) {
    pair<int, int> p1 = v2[i];
    pair<int, int> p2 = v2[v2.size() - 1 - i];
    if (p1.second == p2.second) {
      if (p1.first + p2.first == k) {
        removed2 += k;
      } else {
        removed2 += (p1.first + p2.first) / k * k;
        break;
      }
    } else {
      break;
    }
  }
  long long int ans = 0;
  if (i == (v2.size() + 1) / 2) {
    if (m % 2 == 0) {
      ans = 0;
    } else {
      ans = n - removed;
    }
  } else if (i == (v2.size() + 1) / 2 - 1 && v2.size() % 2 == 1) {
    if ((long long int)m * v2[i].first % k == 0) {
      ans = 0;
    } else {
      ans = (long long int)m * v2[i].first % k + n - removed - v2[i].first;
    }
  } else {
    ans = (long long int)m * (n - removed) - (long long int)(m - 1) * removed2;
  }
  cout << ans << endl;
}
int main() {
  read_data();
  merge_two_bus();
  return 0;
}
