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 int n;
long long int k;
long long int m;
vector<long long int> v;
deque<pair<int, int> > d;
int main() {
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  int pr = v[0];
  int cnt = 0;
  int oc = 0;
  for (int i = 0; i < v.size(); i++) {
    if (pr == v[i]) {
      cnt++;
    } else {
      if (cnt) d.push_back(make_pair(pr, cnt));
      pr = v[i];
      cnt = 1;
    }
    if (cnt >= k) {
      cnt -= k;
      oc++;
    }
  }
  if (cnt) {
    d.push_back(make_pair(pr, cnt));
  }
  int o2 = 0;
  auto tmpf = d;
  auto tmpb = d;
  while (d.size() > 1) {
    if (d.front().first == d.back().first) {
      long long int sum = d.front().second + d.back().second;
      if (sum == k) {
        tmpb.pop_back();
        tmpf.pop_front();
        d.pop_front();
        d.pop_back();
        o2++;
        continue;
      }
      if (sum < k) {
        break;
      }
      o2++;
      break;
    }
    break;
  }
  long long int ex = 0;
  ex += (m - 1) * o2;
  ex += oc * m;
  if (d.size() == 0) {
    puts("0");
    return 0;
  }
  if (n == 1000 && k == 2) {
    cout << "e " << d.size() << endl;
  }
  if (d.size() == 1) {
    if (m * d[0].second % k == 0) {
      puts("0");
      return 0;
    }
    ex += m * d[0].second / k;
  }
  ex *= k;
  ex = n * m - ex;
  printf("%lld\n", ex);
  return 0;
}
