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, ans, k, m, a[100010];
vector<pair<long long, long long> > s;
bool added[100010];
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> k >> m;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    if (s.empty()) {
      s.push_back({a[i], 1});
    } else if (s.back().first != a[i]) {
      s.push_back({a[i], 1});
    } else {
      long long num = s.back().second;
      s.pop_back();
      ++num;
      if (num < k) {
        s.push_back({a[i], num});
      }
    }
  }
  if (m == 1) {
    for (auto x : s) {
      ans += x.second;
    }
    cout << ans;
    return 0;
  }
  long long grNum = 0, numCombined;
  for (long long i = 0; i < s.size(); ++i) {
    if (i >= s.size() - i - 1) {
      break;
    }
    auto l = s[i], r = s[s.size() - i - 1];
    if (l.first == r.first and l.second + r.second == k) {
      ++grNum;
    } else {
      break;
    }
  }
  if (grNum * 2 == s.size()) {
    if (m & 1) {
      for (auto x : s) {
        ans += x.second;
      }
    }
    cout << ans << '\n';
    return 0;
  }
  if (grNum == s.size() / 2 and s.size() % 2) {
    if (m * s[grNum].second % k == 0) {
      cout << 0;
    } else {
      ans += m * s[grNum].second % k;
      for (long long i = 0; i < grNum; ++i) {
        ans += s[i].second;
      }
      for (long long i = grNum + 1; i < s.size(); ++i) {
        ans += s[i].second;
      }
      cout << ans;
    }
    return 0;
  }
  for (long long i = 0; i < s.size(); ++i) {
    if (i < grNum or i > s.size() - grNum - 1) {
      ans += s[i].second;
      continue;
    }
    if (i == grNum and i != s.size() - i - 1 and
        s[i].first == s[s.size() - i - 1].first) {
      long long tmp = s[i].second + s[s.size() - i - 1].second;
      ans += (m - 1) * (tmp % k);
      ans += s[i].second;
      ans += s[s.size() - i - 1].second;
      added[i] = 1;
      added[s.size() - i - 1] = 1;
      continue;
    }
    if (added[i]) {
      continue;
    }
    ans += m * s[i].second;
  }
  cout << ans << '\n';
}
