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 main() {
  int n, k, m;
  cin >> n >> k >> m;
  vector<pair<int, int> > a;
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    if (a.empty() || a.back().first != b)
      a.push_back(make_pair(b, 1));
    else
      a.back().second++;
    if (a.back().second == k) a.pop_back();
  }
  long long ans = 0;
  for (auto x : a) ans += x.second;
  int p = a.size();
  if (m == 1) {
  } else {
    ans = ans * m;
    int l = 0, r = p - 1;
    while (l < r) {
      long long sm = a[l].second + a[r].second;
      if (a[l].first != a[r].first || sm < k) {
        break;
      }
      if (sm == k) {
        ans -= (m - 1) * sm;
        l++, r--;
      } else {
        ans -= long long(m - 1) * k;
        break;
      }
    }
    if (l == r) {
      long long tot = a[l].second * m;
      if (tot % k == 0)
        ans = 0;
      else
        ans -= (tot / k) * k;
    }
  }
  cout << ans << endl;
}
