#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int main() {
  scanf("%d %d %d", &n, &k, &m);
  long long ans = 1LL * n * m;
  vector<pair<int, int> > v;
  for (int i = int(1); i < int(n + 1); i++) {
    int cur;
    scanf("%d", &cur);
    if (v.empty() || v.back().first != cur) {
      v.emplace_back(cur, 1);
    } else {
      v[v.size() - 1].second++;
    }
    if (v.back().second == k) {
      v.pop_back();
      ans -= 1LL * k * m;
    }
  }
  if (m > 1) {
    if (v.size() == 1) {
      long long has = 1LL * m * v[0].second;
      ans = has % k;
      printf("%lld\n", ans);
      return 0;
    }
    int removed = 0, last = v.size();
    for (int i = int(v.size() - 1); i >= int(0); i--) {
      int other = v.size() - 1 - i;
      int sum = v[i].second + v[other].second;
      if (v[i].first != v[other].first) {
        break;
      }
      last = i;
      if (sum < k) {
        break;
      } else if (sum == k) {
        removed++;
      } else if (sum > k) {
        if (i != other) {
          removed++;
        }
        break;
      }
    }
    if (removed == (int)v.size()) {
      long long rest = 0;
      for (auto &each : v) {
        rest += each.second;
      }
      ans = m % 2 == 0 ? 0 : rest;
    } else {
      ans -= 1LL * removed * k * (m - 1);
      if ((int)v.size() - last - 1 == last) {
        long long has = 1LL * m * v[last].second;
        long long to_rem = (has / k) * k;
        if (has == to_rem) {
          ans = 0;
        } else {
          ans -= (has / k) * k;
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
